How to use JUnit (Versions 3 and 4)

JUnit can only test methods, not general input/output of a program. For general input/output one needs blackbox tests or one needs to write a method that returns the output before it is actually printed.

Hello World example
JUnit 3 example

Apart from assertEquals, other tests can be used (delta sets the precision for float and double):

Examples of other tests

The test should be uploaded as a .java file using the "Create File Checker" and be used with the JUnit Checker. The class file of the test will be generated by the Praktomat. Note: in the Create File Checker the filename should be the java file of the test, whereas in the JUnit Checker the class filename should be provided. In case of JUnit 4 the class should be provided without the extension "class". The tests should not be compiled as part of a package. Further documentation can be found on the JUnit 3 and JUnit 4 websites.

 


eCULT BMBF
Software und Dokumente der ProFormA-Gruppe der Ostfalia
https://elearning-ostfalia.github.io/proforma/

Dieses Vorhaben wurde aus Mitteln des Bundesministeriums für Bildung und Forschung unter den Förderkennzeichen 01PL11066H und 01PL16066H gefördert. Die Verantwortung für den Inhalt dieser Webseite liegt bei den Autorinnen.