mirror of
https://github.com/smyalygames/kahoot-challenge-2025.git
synced 2025-05-18 13:04:14 +02:00
refactor(test): move arguments variable to class
This commit is contained in:
parent
5041ac1f74
commit
80c7f92e88
@ -13,8 +13,8 @@ class MainTest {
|
||||
|
||||
// File handling variables
|
||||
@TempDir
|
||||
static Path tempDir;
|
||||
static Path tempFile;
|
||||
private static Path tempDir;
|
||||
private static Path tempFile;
|
||||
|
||||
// PrintStream (to capture the console output)
|
||||
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||
@ -24,6 +24,9 @@ class MainTest {
|
||||
private final PrintStream oldOut = System.out;
|
||||
private final PrintStream oldErr = System.err;
|
||||
|
||||
// Argument handling
|
||||
private String[] arguments;
|
||||
|
||||
@BeforeAll
|
||||
static void start() throws IOException {
|
||||
tempFile = Files.createFile(tempDir.resolve("testing.txt"));
|
||||
@ -34,6 +37,9 @@ class MainTest {
|
||||
// Create new PrintStream to capture console outputs
|
||||
System.setOut(new PrintStream(outContent));
|
||||
System.setErr(new PrintStream(errContent));
|
||||
|
||||
// Reset arguments to new array with only 1 item
|
||||
arguments = new String[1];
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@ -46,7 +52,7 @@ class MainTest {
|
||||
@Test
|
||||
@DisplayName("No arguments provided")
|
||||
void noArguments() {
|
||||
String[] arguments = new String[0];
|
||||
arguments = new String[0];
|
||||
|
||||
Main.main(arguments);
|
||||
|
||||
@ -57,7 +63,7 @@ class MainTest {
|
||||
@Test
|
||||
@DisplayName("Too many arguments provided")
|
||||
void tooManyArguments() {
|
||||
String[] arguments = new String[2];
|
||||
arguments = new String[2];
|
||||
// Simulating a potential typo of the path with a space
|
||||
arguments[0] = "/path/to/";
|
||||
arguments[1] = "file.txt";
|
||||
|
Loading…
x
Reference in New Issue
Block a user