File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
main/java/io/github/microcks/testcontainers
test/java/io/github/microcks/testcontainers Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public static void assertSuccess(TestResult testResult) {
4141 if (!failures .isEmpty ()) {
4242 throw new MultipleFailuresError ("Test '" + testResult .getId () + "' has failed" , failures );
4343 }
44+ throw new AssertionFailedError ("Test '" + testResult .getId () + "' is not a success, but has no failure details" );
4445 }
4546 }
4647
Original file line number Diff line number Diff line change @@ -148,4 +148,36 @@ void testPartialFailure() {
148148 fail ("An AssertionFailedError should have been thrown" );
149149 }
150150 }
151+
152+ @ Test
153+ void testFailureWithEmptyCases () {
154+ TestResult result = new TestResult ();
155+ result .setId ("testFailureWithEmptyCases" );
156+ result .setSuccess (false );
157+ result .setTestCaseResults (List .of ());
158+
159+ boolean failed = false ;
160+ try {
161+ Assertions .assertSuccess (result );
162+ } catch (Error error ) {
163+ failed = true ;
164+ assertInstanceOf (AssertionFailedError .class , error );
165+ assertEquals ("Test 'testFailureWithEmptyCases' is not a success, but has no failure details" , error .getMessage ());
166+ }
167+ if (!failed ) {
168+ fail ("An AssertionFailedError should have been thrown" );
169+ }
170+
171+ failed = false ;
172+ try {
173+ Assertions .assertSuccess (result , "op1" );
174+ } catch (Error error ) {
175+ failed = true ;
176+ assertInstanceOf (AssertionFailedError .class , error );
177+ assertEquals ("Test 'testFailureWithEmptyCases' has no test case for operation 'op1'" , error .getMessage ());
178+ }
179+ if (!failed ) {
180+ fail ("An AssertionFailedError should have been thrown" );
181+ }
182+ }
151183}
Original file line number Diff line number Diff line change @@ -318,9 +318,9 @@ private void testMicrocksContractTestingFunctionality(MicrocksContainer microcks
318318 // First test should fail with validation failure messages.
319319 TestResult testResult = microcks .testEndpoint (testRequest );
320320
321- System .err .println (microcks .getLogs ());
322- ObjectMapper mapper = new ObjectMapper ().setSerializationInclusion (JsonInclude .Include .NON_NULL );
323- System .out .println (mapper .writerWithDefaultPrettyPrinter ().writeValueAsString (testResult ));
321+ // System.err.println(microcks.getLogs());
322+ // ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
323+ // System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testResult));
324324
325325 assertFalse (testResult .isSuccess ());
326326 assertEquals ("http://bad-impl:3001" , testResult .getTestedEndpoint ());
You can’t perform that action at this time.
0 commit comments