Package org.protelis.test
Class ProgramTester
- java.lang.Object
-
- org.protelis.test.ProgramTester
-
public final class ProgramTester extends java.lang.ObjectTest a protelis program.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidrunExpectingErrors(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, boolean searchCause, java.lang.String... messageContents)Tests a program expecting an error, and checks its message contents.static voidrunExpectingErrors(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, java.lang.String... messageContents)Tests a program expecting an error, and checks its message contents.static <E extends java.lang.Throwable>
voidrunExpectingErrors(java.lang.String program, java.lang.Class<E> expectedExceptionType, java8.util.function.Consumer<E> analyzer)Tests a program expecting an error, and checks its message contents.static voidrunFile(java.lang.String file)static voidrunFile(java.lang.String file, int runs)static voidrunFile(java.lang.String file, int runs, java.lang.Object expectedResult)static voidrunFileWithExplicitResult(java.lang.String file, java.lang.Object expectedResult)static voidrunFileWithMultipleRuns(java.lang.String file)static voidrunFileWithMultipleRuns(java.lang.String file, int min, int max)static voidrunFileWithMultipleRuns(java.lang.String file, java8.util.stream.IntStream stream)static java.lang.ObjectrunProgram(java.lang.String s, int runs)
-
-
-
Method Detail
-
runFileWithExplicitResult
public static void runFileWithExplicitResult(java.lang.String file, java.lang.Object expectedResult)- Parameters:
file- file to be testedexpectedResult- result
-
runFile
public static void runFile(java.lang.String file)
- Parameters:
file- file to be tested
-
runExpectingErrors
public static void runExpectingErrors(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, boolean searchCause, java.lang.String... messageContents)Tests a program expecting an error, and checks its message contents.- Parameters:
program- the program to execute. It it ends in ".pt", it will be loaded as Protelis script from 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 java.lang.Throwable> void runExpectingErrors(java.lang.String program, java.lang.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. It it ends in ".pt", it will be loaded as Protelis script from classpathexpectedExceptionType- the type of exception to be thrownanalyzer- the actions to perform on the exception
-
runExpectingErrors
public static void runExpectingErrors(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, java.lang.String... messageContents)Tests a program expecting an error, and checks its message contents.- Parameters:
program- the program to execute. It it ends in ".pt", it will be loaded as Protelis script from classpathexpectedExceptionType- the type of exception to be thrownmessageContents- the strings that the exception message must include
-
runFileWithMultipleRuns
public static void runFileWithMultipleRuns(java.lang.String file)
- Parameters:
file- file to be tested
-
runFileWithMultipleRuns
public static void runFileWithMultipleRuns(java.lang.String file, int min, int max)- Parameters:
file- file to be testedmin- min runsmax- max runs
-
runFileWithMultipleRuns
public static void runFileWithMultipleRuns(java.lang.String file, java8.util.stream.IntStream stream)- Parameters:
file- file to be testedstream- stream of run
-
runFile
public static void runFile(java.lang.String file, int runs)- Parameters:
file- file to be testedruns- number of runs
-
runFile
public static void runFile(java.lang.String file, int runs, java.lang.Object expectedResult)- Parameters:
file- file to be testedruns- number of runsexpectedResult- expected result
-
runProgram
public static java.lang.Object runProgram(java.lang.String s, int runs)- Parameters:
s- program to runruns- number of runs- Returns:
- program result
-
-