JUnit Tests - longtomin/FrInMeBa GitHub Wiki
Tests
Classes
For each function of the webserivce is a testclass defined, e.g. testSignUp.java. The packagename is de.radiohacks.frinmeba.test.functions
Control class
There is a java classes where the tests can be controlled, testConfig.java
package de.radiohacks.frinmeba.test;
public class TestConfig {
public final static boolean remote = true;
public final static String URL = "http://localhost:8080/frinmeba/";
}
Test class example
The signup function test ist testing all permutations of the query parameters, e.g. no parameters given, the errortext need to be filled with the right value, see here:
@Test
public void testSignUpNoValues() {
WebTarget target;
if (TestConfig.remote) {
target = ClientBuilder.newClient().target(
TestConfig.URL + functionurl);
} else {
target = target(functionurl);
}
OSiUp out = target.request().get(OSiUp.class);
Assert.assertEquals(Constants.NO_USERNAME_OR_PASSWORD, out.getET());
}
Before each Testclass
With the @BeforeClass where are dropping all tables in the database and create them new, then some informations which are needed for the test are added and the values of the query paramters are stored in variables, see:
@BeforeClass
public static void prepareDB() {
dropDatabaseTables drop = new dropDatabaseTables();
drop.dropTable();
createDatabaseTables create = new createDatabaseTables();
create.createTable();
}
All in all there are more than 200 tests which can be done, to verfiy if the server is running correct.