zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

Standalone reports omit the exception message for failed Java steps

Open Orcus01 opened this issue 4 weeks ago • 1 comments

Bug

When a Java method step throws, the standalone Zerocode reports mark the step as failed but omit the exception message. With #809, the executor log and JUnit failure show the underlying cause. The standalone report still leaves readers looking in the logs for the reason.

Reproduce

Tested with Java 17 on base commit 3f91834d and PR #809 at debef826.

Add this temporary test under core/src/test/java/org/jsmart/zerocode/integrationtests/JavaFailureSmokeTest.java:

package org.jsmart.zerocode.integrationtests;

import org.jsmart.zerocode.core.domain.HostProperties;
import org.jsmart.zerocode.core.domain.JsonTestCase;
import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

@HostProperties(host = "http://localhost", port = 9998, context = "")
@RunWith(ZeroCodeUnitRunner.class)
public class JavaFailureSmokeTest {
    @Test
    @JsonTestCase("unit_test_files/java_apis/03_test_json_java_service_method_Exception.json")
    public void negativeSquareRoot() {}
}

Run mvn -pl core -Dtest=JavaFailureSmokeTest test. The existing fixture calls AddService.squareRoot with -255.0, so the test run is expected to fail. Inspect the generated step report under core/target/zerocode-test-reports/, along with the granular CSV and HTML report.

Actual

This excerpt is from the generated JSON report on #809 (timing and correlation fields omitted):

{
  "name": "javaMethodException",
  "url": "org.jsmart.zerocode.core.AddService",
  "operation": "squareRoot",
  "result": "FAILED",
  "request": "\"-255.0\"",
  "response": "-response unavailable-",
  "assertions": "{Oops! Not decided. Possibly due to non JSON content was encountered. See log for details}"
}

The JSON, granular CSV, and HTML reports mark the step as FAILED on both revisions and omit the underlying cause. On #809, the executor log and JUnit failure contain Cause: java.lang.RuntimeException: Can not square root a negative number.

Expected

The standalone report shows the Java step's failure reason alongside the failed result, so the cause is visible without opening the logs.

Missing the reason why this test failed, the following generic message is not enough 🔴 :

  "assertions": "{Oops! Not decided. Possibly due to non JSON content was encountered. See log for details}"

Follow-up to #808 and #809, as requested in https://github.com/authorjapps/zerocode/issues/808#issuecomment-6685897137.

Orcus01 avatar Nov 06 '26 13:11 Orcus01

I reran the negative square-root scenario locally with #809 and #815 together. The standalone HTML report now shows the underlying exception under Reason. The screenshot is from that local run.

Image

Orcus01 avatar Nov 08 '26 15:11 Orcus01