package aalgTest;

import java.util.LinkedList;
import java.util.List;

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class AllTests {

	private static final Class<?>[] classArray = {
		MatrixTest.class,
		PrimeFieldTest.class,
		GroupTest.class,
		MultiMonoidGeneratorTest.class,
		MultiGroupTest.class,
		DHTest.class,
		DsaTest.class,
		HashTest.class,
		Pkcs7PaddingTest.class,
		AesTest.class,
		CbcStreamCipherTest.class,
		CtrStreamCipherTest.class,
		DHStreamCipherTest.class,
		AnonymousAuthenticationTest.class,
		CtrIncrementTest.class,
		VariableNumberIoTest.class
	};
	
	public static final void main (final String[] args) {
		final JUnitCore junitCore = new JUnitCore();
		final List<Class<?>> failedTests = new LinkedList<Class<?>>();
		
		for (Class<?> testClass: classArray) {
			final Result result = junitCore.run(testClass);
			
			if (!result.wasSuccessful()) {
				final List<Failure> failureList = result.getFailures();
			
				for (Failure failure: failureList)
					System.out.println (failure.toString());
				
				failedTests.add(testClass);
			}
		}
		
		if (failedTests.isEmpty())
			System.out.println("All tests succeeded");
		else {
			System.out.println("Some test(s) failed:");
			
			for (Class<?> testClass: failedTests) {
				System.out.println (testClass.getName());
			}
		}
	}
}
