Public:Automatic tests
From YaddaWiki
(Created page with "=Tests= Tests are significant part of the programming effort. They not only have to be written, but to be maintained with rest of the code as well. Therefore following rules app…")
Newer edit →
Revision as of 06:23, 2 July 2018
Contents |
Tests
Tests are significant part of the programming effort. They not only have to be written, but to be maintained with rest of the code as well. Therefore following rules apply:
Separation of the unit and integration tests
Unit tests are tests, which do not require specific environment to be run, and may be run during each compilation.
Integration tests require specific environment and are not expected to be run during each compilation.
Unit test location
All unit tests are located within standard maven directory structure, in:
src/test/java
All resources required by tests, but not required by the executable code are stored in:
src/test/resources
Unit tests are tests for the classes, so:
- tests referring to the custom class are in the same package as tested class
- tests for the class are in class named ClassNameTest, e.g. for StringConverter tests are StringConverterTest
Test method naming
All testing methods must have clear and significant names. It is recommended, that each test method has name test<MethodName>, for method formatString() it would be:
testFormatString()
Or - if there are more than one method with the same name - add a suffix explaining method, starting with a dash (_), e.g.:
testFormatString_2args() testFormatString_4args()
If for some reason you want to have more than one test for one method add significant soffix explaining test purpouse:
testFormatString_Diacretics() testFormatString_HtmlEscapes()