Package org.protelis.test
Class ProgramTester
java.lang.Object
org.protelis.test.ProgramTester
Test a protelis program.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidrunExpectingErrors(String program, Class<? extends Throwable> expectedExceptionType, boolean searchCause, String... messageContents) Tests a program expecting an error and checks its message contents.static voidrunExpectingErrors(String program, Class<? extends Throwable> expectedExceptionType, String... messageContents) Tests a program expecting an error and checks its message contents.static <E extends Throwable>
voidrunExpectingErrors(String program, Class<E> expectedExceptionType, java8.util.function.Consumer<E> analyzer) Tests a program expecting an error and checks its message contents.static voidstatic voidstatic voidstatic voidrunFileWithExplicitResult(String file, Object expectedResult) static voidstatic voidrunFileWithMultipleRuns(String file, int min, int max) static voidrunFileWithMultipleRuns(String file, java8.util.stream.IntStream stream) static ObjectrunProgram(String s, int runs)
-
Method Details
-
runFileWithExplicitResult
- Parameters:
file- file to be testedexpectedResult- result
-
runFile
- Parameters:
file- file to be tested
-
runFile
- Parameters:
file- file to be testedruns- number of runsexpectedResult- expected result
-
runFile
- Parameters:
file- file to be testedruns- number of runs
-
runExpectingErrors
public static void runExpectingErrors(String program, Class<? extends Throwable> expectedExceptionType, boolean searchCause, String... messageContents) Tests a program expecting an error and checks its message contents.- Parameters:
program- the program to execute. If it ends in ".pt", it will be loaded as a Protelis script from the classpathexpectedExceptionType- the type of exception to be thrownsearchCause- if true, the message contents are searched for in the cause exception messagemessageContents- the strings that the exception message must include
-
runExpectingErrors
public static <E extends Throwable> void runExpectingErrors(String program, Class<E> expectedExceptionType, java8.util.function.Consumer<E> analyzer) Tests a program expecting an error and checks its message contents.- Type Parameters:
E- exception type (static)- Parameters:
program- the program to execute. If it ends in ".pt", it will be loaded as a Protelis script from the classpathexpectedExceptionType- the type of exception to be thrownanalyzer- the actions to perform on the exception
-
runExpectingErrors
public static void runExpectingErrors(String program, Class<? extends Throwable> expectedExceptionType, String... messageContents) Tests a program expecting an error and checks its message contents.- Parameters:
program- the program to execute. If it ends in ".pt", it will be loaded as a Protelis script from the classpathexpectedExceptionType- the type of exception to be thrownmessageContents- the strings that the exception message must include
-
runFileWithMultipleRuns
- Parameters:
file- file to be tested
-
runFileWithMultipleRuns
- Parameters:
file- file to be testedmin- min runsmax- max runs
-
runFileWithMultipleRuns
- Parameters:
file- file to be testedstream- stream of runs
-
runProgram
- Parameters:
s- program to runruns- number of runs- Returns:
- program result
-