Class ProgramTest

java.lang.Object
com.gophers.services.testCases.ProgramTest

public class ProgramTest extends Object
The ProgramTest class provides a suite of tests to verify the functionality of the code, ensuring that it compiles and runs successfully.

This test class includes tests for compiling the submitted code and running the main method of the "ChatBotSimulation" class. It uses JUnit for testing and captures the system output for validation.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for the ProgramTest class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Sets up the test environment by redirecting the `System.out` stream to capture output generated during the tests.
    void
    Restores the original `System.out` stream after each test has run.
    void
    Tests that the `compile` method of the `JavaCompileCommand` correctly compiles the submission without errors.
    void
    Tests that the `main` method of the `ChatBotSimulation` class runs successfully.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProgramTest

      public ProgramTest()
      Default constructor for the ProgramTest class. Initializes a new instance of the ProgramTest class to test program functionality.
  • Method Details

    • testCompiles

      public void testCompiles()
      Tests that the `compile` method of the `JavaCompileCommand` correctly compiles the submission without errors. This test ensures that the submission code in the specified directory can be successfully compiled without issues.
    • testRuns

      public void testRuns()
      Tests that the `main` method of the `ChatBotSimulation` class runs successfully. This test verifies that invoking the `main` method of the `ChatBotSimulation` class does not throw any exceptions and completes without errors.
    • setUp

      public void setUp()
      Sets up the test environment by redirecting the `System.out` stream to capture output generated during the tests. This method is run before each test to ensure that the output stream is redirected for capturing test results.
    • tearDown

      public void tearDown()
      Restores the original `System.out` stream after each test has run. This method is executed after each test to restore the original output stream and prevent interference with other tests.