How Can jBilling Help You?
Who’s Using jBilling?

“From our experience to date, we couldn't have made a better decision.”
Daniel Goepp
Vidtel
See all testimonials >

Testing jBilling

Every time there are changes in the source code, we need to do a sanity test. This is a set of tests that goes over the main functions of jbilling, making sure that they are still doing what they should do. An experienced user can do these tests in less than 10 minutes; a great value for so little time! This sanity test is just an addition to the actual unit test that you would do to test the specific behaviour that the changes you’ve introduced to the code are addressing.

There are two set of tests, one is done by using the web based graphic user interface (GUI testing). Here you do as if you were a customer clicking on menu options and manually entering values. The second test is an automated test included in the build scripts and based on JUnit.


GUI testing

First of all, read the getting started guide. You do it only once to get familiar with jbilling, it takes about 20 minutes and it will save you time, because you won’t have to wonder around the menu options later on.

  1. Start by editing jbilling.properties. We want the billing process to start five minutes after start-up and then every 5 minutes:

process.time=

process.frequency=5

  1. Start-up jbilling. Login as an administrator

  2. Create an item type

  3. Create an item

  4. Create a new customer

  5. Create an order for this customer. Make it monthly and pre-paid. Add in it the item you’ve created in step 4

  6. Click on Process -> Configuration. Change the next run date to today, and leave unchecked the check-box for ‘Requires review’.

  7. Click on Process -> Latest. Most probably you won’t see any information yet. You have to wait until the scheduled billing process is triggered. This should be a minute or two, since in step 1 you’ve configured the billing process to run every 5 minutes. Refresh this screen until you get to see some data.

  8. You should get only one invoice generated in the billing process. Click on it, make sure the total corresponds to the order you’ve created in step 6.

  9. Click on payments, then credit card, and get the new invoice paid. Verify that the balance goes to zero and the status to ‘paid’.


JUnit (automated testing)

  1. Make sure jbilling is down: jbilling/bin/shutdown.sh

  2. Install postgres and create a database called 'jbilling_test' with a user 'jbilling' (no password) that has all privileges in this database.

  3. Run jbilling/src/ant prepare-test. This will create the tables and add all the test data to the postgres database. If you get an 'out of memory' error, you need to increase the Java memory. Something like this works on linux: export ANT_OPTS=-Xmx512m

  4. Configure your jBilling installation to use postgres instead of the default HSQL. To do this, edit the configuration file jbilling-database.xml and copy the postgres JDBC driver to the lib directory (there are more details on this configuration in this page, but not all that is in that page needs to be done).

  5. Start-up jbilling: jbilling/bin/startup.sh

  6. Run jbilling/src/ant test-ws. This is the fast automated test. You should this one often, it touches many components and is doable in a few minutes.

  7. Run jbilling/src/ant test. This should be done only when you think you are done. It does a full billing process and mediation test, and it takes over an hour. The message you are looking for is ‘BUILD SUCCESSFUL’. Note that the file server.log will have plenty of exception even when you've got a successsfull test.