Panier  

Aucun produit

Expédition 0,00 €
Taxes 0,00 €
Total 0,00 €

Les prix sont TTC

Panier Commander

Catégories

Newsletter

 

Java : sturdiness, auto test unit tests and test coverage

 

The context

Java implementation is subject to various changes during a project's life.

Even if the initial release is stable and validated, after a few weeks/months, the quality decreases.

 

The Scan2Fix purpose

In order to keep a mesurable level of stability, we propose to combine :

  • the Scan2Fix4Java source code analyzer
  • the AutoTest source code generator

 

The first tool is designed to analyse the Java source code and rveal violations, especialy Null Pointer Exception potential occurrences (CWE476 see http://cwe.mitre.org/data/definitions/476.html). The Scan2Fix4Java identifies in particular NPE risks on method arguments. These missings are very frequent. The sturdiness of a class is very low when arguments are not properly controlled.

 

The second toll is designed to generate a wide bunch of Java Junit tests. In fact we generate blind tests fo each method : each value of all the arguments is tested against predefined values. For example the method myMethod(int a, boolean b, MyClass c) is tested with the values :

  • a in {-10000, -1000, -1, 0, 1, etc}
  • b in {true, false}
  • c in {null, new MyClass()}

 

These blind and automatic tests must succeed to ensure the sturdiness of myMethod. The test coverage is also highly improved.

 

How to

Scan2Fix4Java is a Maven plugin. It is designed to analyse the Java source code and produces property files (mvn qcr:qcrgoalcompile).

Then the Autotest Junit files are produced by mvn qcr:qcrgoalgenerateautotestsources command.

The Junit test source code files are generated in the src/test directory, and are ready to be compiled/executed (all files are prefixed by QcrAutoTest and postfixed by Test in order for Junit to detect them). In the example the QrAutoTestMyClassTest.java is produced.

 

The Maven plugin goal is available in the Scan2Fix4Java product.

 

Benefits

Autotest Junit automates the generation of Junit tests

Sturdiness improvment, iterative bug fix

Test coverage improvment