mirror of
https://codeberg.org/PGPainless/wkd-java.git
synced 2024-11-21 14:52:12 +01:00
Introduce enum value for test case expectation to enable modelling of unassertive tests!
This commit is contained in:
parent
a91b6660bb
commit
40d5d6eba6
2 changed files with 21 additions and 7 deletions
|
@ -66,7 +66,7 @@ public class TestSuiteTestRunner {
|
||||||
|
|
||||||
if (testCase.isExpectSuccess()) {
|
if (testCase.isExpectSuccess()) {
|
||||||
assertEquals(0, exitCode, testCase.getTestDescription());
|
assertEquals(0, exitCode, testCase.getTestDescription());
|
||||||
} else {
|
} else if (testCase.isExpectFailure()) {
|
||||||
assertNotEquals(0, exitCode, testCase.getTestDescription());
|
assertNotEquals(0, exitCode, testCase.getTestDescription());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,15 +9,21 @@ import java.nio.file.Path;
|
||||||
|
|
||||||
public class TestCase {
|
public class TestCase {
|
||||||
|
|
||||||
final boolean expectSuccess;
|
enum Expectation {
|
||||||
|
success,
|
||||||
|
failure,
|
||||||
|
unassertive
|
||||||
|
}
|
||||||
|
|
||||||
|
final Expectation expectation;
|
||||||
final String testTitle;
|
final String testTitle;
|
||||||
final String testDescription;
|
final String testDescription;
|
||||||
final String lookupMailAddress;
|
final String lookupMailAddress;
|
||||||
final String certificatePath;
|
final String certificatePath;
|
||||||
final URI lookupUri;
|
final URI lookupUri;
|
||||||
|
|
||||||
public TestCase(boolean expectSuccess, String testTitle, String description, String lookupMailAddress, Path certificatePath, URI lookupUri) {
|
public TestCase(Expectation expectation, String testTitle, String description, String lookupMailAddress, Path certificatePath, URI lookupUri) {
|
||||||
this.expectSuccess = expectSuccess;
|
this.expectation = expectation;
|
||||||
this.testTitle = testTitle;
|
this.testTitle = testTitle;
|
||||||
this.testDescription = description;
|
this.testDescription = description;
|
||||||
this.lookupMailAddress = lookupMailAddress;
|
this.lookupMailAddress = lookupMailAddress;
|
||||||
|
@ -28,17 +34,25 @@ public class TestCase {
|
||||||
public static TestCase ok(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
public static TestCase ok(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
||||||
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
||||||
URI certUri = structure.getAddress(lookupMail);
|
URI certUri = structure.getAddress(lookupMail);
|
||||||
return new TestCase(true, title, description, lookupMail, filePath, certUri);
|
return new TestCase(Expectation.success, title, description, lookupMail, filePath, certUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TestCase fail(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
public static TestCase fail(String title, String description, String lookupMail, WkdDirectoryStructure structure) {
|
||||||
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
Path filePath = structure.getRelativeCertificatePath(lookupMail);
|
||||||
URI certUri = structure.getAddress(lookupMail);
|
URI certUri = structure.getAddress(lookupMail);
|
||||||
return new TestCase(false, title, description, lookupMail, filePath, certUri);
|
return new TestCase(Expectation.failure, title, description, lookupMail, filePath, certUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpectSuccess() {
|
public boolean isExpectSuccess() {
|
||||||
return expectSuccess;
|
return expectation == Expectation.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpectFailure() {
|
||||||
|
return expectation == Expectation.failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnassertive() {
|
||||||
|
return expectation == Expectation.unassertive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTestTitle() {
|
public String getTestTitle() {
|
||||||
|
|
Loading…
Reference in a new issue