Every time there are changes in the source code, we need to do a sanity test. This is a set of tests that go 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. This sanity test is just an addition to the actual unit test that you would conduct to check the specific behavior that your code changes have created.
There are two sets of tests. One is done by using the web based graphic user interface (GUI testing). Here you test as if you were a customer clicking on menu options and manually entering values. The second test is an automated process that is included in the build scripts and based on JUnit.
Before you begin, read the Getting Started guide. You only need to do this once to familiarize yourself with jBilling. It takes about 20 minutes and it will save you time, since you won’t have to wander around the menu options later on.
Start by editing jbilling.properties. We want the billing process to start five minutes after start up, and then run every five minutes:
- Start up jBilling. Login as an administrator.
- Create an item type.
- Create an item.
- Create a new customer.
- Create an order for this customer. Make it monthly and pre-paid. Add the item you created in step 4.
- Click on Process -> Configuration. Change the next run date to today, and leave unchecked the checkbox for ‘Requires review.’
- Click on Process -> Latest. You probably 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 you configured the billing process to run every five minutes in step 1. Refresh this screen until you see some data.
- Only one invoice should be generated in the billing process. Click on it and make sure the total corresponds to the order you created in step 6.
- 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)
- Make sure jBilling is down: jbilling/bin/shutdown.sh
- Install postgres and create a database called 'jbilling_test' with a user 'jbilling' (no password) that has all privileges in this database.
- 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
- 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 page, but not all of the configuration needs to be completed).
- Start-up jbilling: jbilling/bin/startup.sh
- Run jbilling/src/ant test-ws. This is the fast automated test. You should conduct this one often because it touches many components and can be completed in a few minutes.
- Run jbilling/src/ant test. This should be done only when you think you are finished. 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 exceptions even when you have a successful test.