Tests - ninazeina/SXP GitHub Wiki

Launching all tests

Tests are launched with each gradle build, which may be comprised in a gradle run if the first.
However, they can also be launched with

gradle test  
firefox build/reports/tests/index.html  

Launching the tests of one module

For instance, in order to launch the tests of the crypt module only

gradle test --tests crypt*

Conventions for test files

Tests files locations follow the gradle convention: e.g. src/test/java/crypt/impl contains the tests for the implementation files of the crypt module.

Tests files names follow the convention XTest, where X is the name of the class being tested.

Tests files contents follow the JUnit convention.

package crypt.impl; //locate yourself in same package as class being tested

import static org.junit.Assert.*; //JUnit
import org.junit.Test;

import ...; //other dependencies 

public class XTest {
	private static final String plainText = "tatata";

	@Test   //annotate this as a test
	public void test() { //name of method does not matter, often that of the method being tested
		...
		assertTrue(...);
	}
}