Reference exit codes directly in junit tests

This commit is contained in:
Paul Schaub 2022-06-11 11:18:45 +02:00
parent 0c24c2301d
commit 61ab35ad52
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
11 changed files with 72 additions and 63 deletions

View file

@ -14,6 +14,7 @@ import java.util.List;
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
import org.junit.jupiter.api.Test;
import sop.SOP;
import sop.exception.SOPGPException;
import sop.operation.Armor;
import sop.operation.Dearmor;
import sop.operation.Decrypt;
@ -30,7 +31,7 @@ import sop.operation.Version;
public class SOPTest {
@Test
@ExpectSystemExitWithStatus(69)
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedSubcommand.EXIT_CODE)
public void assertExitOnInvalidSubcommand() {
SOP sop = mock(SOP.class);
SopCLI.setSopInstance(sop);
@ -125,7 +126,8 @@ public class SOPTest {
for (String[] command : commands) {
int exit = SopCLI.execute(command);
assertEquals(69, exit, "Unexpected exit code for non-implemented command " + Arrays.toString(command) + ": " + exit);
assertEquals(SOPGPException.UnsupportedSubcommand.EXIT_CODE, exit,
"Unexpected exit code for non-implemented command " + Arrays.toString(command) + ": " + exit);
}
}
}