--- Tests --- Andrés Gómez Casanova --- 2010-03-08 ---
Tests
There are many tests for the application. Almost every method of every class have at lest one tests.
Type of tests
There are three type of tests:
- Unit tests: tests the parameters (null, ranges, types), and internal function.
- Integration tests: tests the communication between components.
- Message tests: the generated output is tested, comparing the messages.
The suite of tests uses the Java assertions in order to assure that the input parameters are according to the method signature. In addition, the suite of tests uses some specific configuration, such as a particular configuration for the application, and a simplified grammar.
Eclipse configuration
In order to have this environment in Eclipse, you have to do the following:
- Look for the class AllTests.java in the source-code/tests/src/test/java directory, in the package name.angoca.zemucan.
- Right click in the class name. In the contextual menu, click in 'Run As', 'Run Configurations...'
- In the new window, at the left, select JUnit as type of execution. Then, click in the 'New launch configuration' button at upper left.
- At right, you must see in the Name field 'AllTests'.
- Then, in the first tab called Tests, you will see in the Test class field name.angoca.zemucan.AllTests, in the Test runner list JUnit 4.
- In the second tab, called Arguments, you have to write in the VM argument field '-ea' that means Enable assertions. In the Working directory field, you select Other, and then click in the Workspace button, select the current project (something called like Zemucan) and then select the bin directory in the list, by clicking Ok. Now, you are in the Run Configurations window, and you can click in the Apply button.
- Finally, you can execute the tests by clicking in the button Run.
It will activate a view called Junit and you will see how the tests are executed.
Notes
If you don't activate the Assertions, you will wee many problems about null parameters, and also an infinitive loop in the nodeFusion method of Graph class. However, that's normal, because the suite of tests, try to tests the internals of the application, and this part is never like that, it has a set of verifications, before to arrive to this point.
If you don't select to bin directory, there will be many errors related to the "File cannot be found", and its normal, because the execution directory for a normal Eclipse execution, is the project directory, and not the bin directory. So, when running that, the tests cannot found the necessary files.
jUnit integration
AllTests.java is the class that has all the tests, Integration, Messages and Unit. This class could be directly executed because it tells to JUnit 4 what to execute:
@RunWith(Suite.class)
@SuiteClasses( { UnitTests.class, IntegrationTests.class, MessagesTests.class })