Class ChatBotSimulationTest

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

public class ChatBotSimulationTest extends Object
Test suite for the ChatBotSimulation class that verifies various aspects of the chat bot system. This class tests the initialization, interaction, and statistical tracking of multiple chat bots. The tests cover requirements including setup, bot creation, message handling, and summary statistics.
  • Constructor Details

    • ChatBotSimulationTest

      public ChatBotSimulationTest()
  • Method Details

    • setUp

      public void setUp() throws Exception
      Sets up the test environment before each test. Initializes the main method reference, redirects System.out to a capturable stream, and resets any static fields to ensure clean test state.
      Throws:
      Exception - if setup fails
    • resetStaticFields

      public void resetStaticFields()
      Resets static fields in the ChatBot class to ensure each test starts fresh. Specifically resets the messageNumber counter to 0.
    • tearDown

      public void tearDown()
      Restores the original System.out after each test.
    • testMainMethodStartsWithHelloWorld

      public void testMainMethodStartsWithHelloWorld() throws Exception
      Tests if the main method correctly outputs "Hello World!" at the start. Verifies requirement 1 of the chat bot simulation. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testChatBotPlatformInitialization

      public void testChatBotPlatformInitialization()
      Verifies that ChatBotPlatform is properly initialized in the main method. Checks for the presence of the initialization line in the source code. Worth 1 mark.
    • testAllChatBotModelsPresent

      public void testAllChatBotModelsPresent() throws Exception
      Tests if all required chat bot models are present in the simulation. Verifies that LLaMa, Mistral7B, Bard, Claude, Solar, and ChatGPT-3.5 are included. Worth 2 marks.
      Throws:
      Exception - if the test fails
    • testChatBotsSectionPresent

      public void testChatBotsSectionPresent() throws Exception
      Verifies that the "Your ChatBots" section is present in the output. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testInitialSummaryStatistics

      public void testInitialSummaryStatistics() throws Exception
      Tests if the initial summary statistics are correctly displayed. Checks for "Total Messages Used: 0" and "Total Messages Remaining: 10". Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testAtLeastOneInteractionOccurred

      public void testAtLeastOneInteractionOccurred() throws Exception
      Verifies that at least one chat bot interaction occurred. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testMessageNumberFormatInBotResponses

      public void testMessageNumberFormatInBotResponses() throws Exception
      Tests if bot responses follow the correct message number format "(Message#...)". Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testInvalidBotNumberResponsePresent

      public void testInvalidBotNumberResponsePresent() throws Exception
      Verifies that incorrect bot number errors are handled and displayed. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testSimulationPerformsExactlyFifteenInteractions

      public void testSimulationPerformsExactlyFifteenInteractions() throws Exception
      Tests if the simulation performs exactly 15 interactions. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testFinalSummaryNotEmpty

      public void testFinalSummaryNotEmpty() throws Exception
      Verifies that the final summary section is not empty. Worth 1 mark.
      Throws:
      Exception - if the test fails
    • testFinalSummaryStatistics

      public void testFinalSummaryStatistics() throws Exception
      Tests if the final summary contains all required statistics. Checks for total messages used and remaining, and verifies their values. Worth 1 mark.
      Throws:
      Exception - if the test fails