forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from HengShuHong/master
Add JUnit Test for ExitCommand and HelpCommand
- Loading branch information
Showing
4 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,5 @@ public static boolean getIsExit() { | |
|
||
@Override | ||
public void execute() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package command; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ExitCommandTest { | ||
@Test | ||
public void testGetIsExit() { | ||
ExitCommand exitCommand = new ExitCommand(true); | ||
assertTrue(ExitCommand.getIsExit()); | ||
} | ||
|
||
@Test | ||
public void testExecute() { | ||
ExitCommand exitCommand = new ExitCommand(false); | ||
exitCommand.execute(); | ||
assertFalse(ExitCommand.getIsExit()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package command; | ||
|
||
import common.Messages; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class HelpCommandTest { | ||
@Test | ||
public void testExecute() { | ||
ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); | ||
System.setOut(new PrintStream(outputStreamCaptor)); | ||
HelpCommand helpCommand = new HelpCommand(); | ||
helpCommand.execute(); | ||
String expectedOutput = Messages.HELP + System.lineSeparator(); | ||
assertEquals(expectedOutput, outputStreamCaptor.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters