Class ProgramTester

java.lang.Object
org.protelis.test.ProgramTester

public final class ProgramTester extends Object
Test a protelis program.
  • Method Details

    • runFileWithExplicitResult

      public static void runFileWithExplicitResult(String file, Object expectedResult)
      Parameters:
      file - file to be tested
      expectedResult - result
    • runFile

      public static void runFile(String file)
      Parameters:
      file - file to be tested
    • runFile

      public static void runFile(String file, int runs, Object expectedResult)
      Parameters:
      file - file to be tested
      runs - number of runs
      expectedResult - expected result
    • runFile

      public static void runFile(String file, int runs)
      Parameters:
      file - file to be tested
      runs - 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 classpath
      expectedExceptionType - the type of exception to be thrown
      searchCause - if true, the message contents are searched for in the cause exception message
      messageContents - 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 classpath
      expectedExceptionType - the type of exception to be thrown
      analyzer - 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 classpath
      expectedExceptionType - the type of exception to be thrown
      messageContents - the strings that the exception message must include
    • runFileWithMultipleRuns

      public static void runFileWithMultipleRuns(String file)
      Parameters:
      file - file to be tested
    • runFileWithMultipleRuns

      public static void runFileWithMultipleRuns(String file, int min, int max)
      Parameters:
      file - file to be tested
      min - min runs
      max - max runs
    • runFileWithMultipleRuns

      public static void runFileWithMultipleRuns(String file, java8.util.stream.IntStream stream)
      Parameters:
      file - file to be tested
      stream - stream of runs
    • runProgram

      public static Object runProgram(String s, int runs)
      Parameters:
      s - program to run
      runs - number of runs
      Returns:
      program result