Package com.gophers.services.testCases
Class ChatBotSimulationTest
java.lang.Object
com.gophers.services.testCases.ChatBotSimulationTest
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidResets static fields in the ChatBot class to ensure each test starts fresh.voidsetUp()Sets up the test environment before each test.voidtearDown()Restores the original System.out after each test.voidTests if all required chat bot models are present in the simulation.voidVerifies that at least one chat bot interaction occurred.voidVerifies that ChatBotPlatform is properly initialized in the main method.voidVerifies that the "Your ChatBots" section is present in the output.voidVerifies that the final summary section is not empty.voidTests if the final summary contains all required statistics.voidTests if the initial summary statistics are correctly displayed.voidVerifies that incorrect bot number errors are handled and displayed.voidTests if the main method correctly outputs "Hello World!" at the start.voidTests if bot responses follow the correct message number format "(Message#...)".voidTests if the simulation performs exactly 15 interactions.
-
Constructor Details
-
ChatBotSimulationTest
public ChatBotSimulationTest()
-
-
Method Details
-
setUp
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
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
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
Verifies that the "Your ChatBots" section is present in the output. Worth 1 mark.- Throws:
Exception- if the test fails
-
testInitialSummaryStatistics
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
Verifies that at least one chat bot interaction occurred. Worth 1 mark.- Throws:
Exception- if the test fails
-
testMessageNumberFormatInBotResponses
Tests if bot responses follow the correct message number format "(Message#...)". Worth 1 mark.- Throws:
Exception- if the test fails
-
testInvalidBotNumberResponsePresent
Verifies that incorrect bot number errors are handled and displayed. Worth 1 mark.- Throws:
Exception- if the test fails
-
testSimulationPerformsExactlyFifteenInteractions
Tests if the simulation performs exactly 15 interactions. Worth 1 mark.- Throws:
Exception- if the test fails
-
testFinalSummaryNotEmpty
Verifies that the final summary section is not empty. Worth 1 mark.- Throws:
Exception- if the test fails
-
testFinalSummaryStatistics
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
-