1

My FullStack tests run on Jenkins and output nothing on success, otherwise the test name and the failed line. This tells nothing about what went wrong.

Is there a way to print the assertion error message on the Jenkins console?

I have a TestWatcher that already takes a screenshot. Should it also do a System.out.println(e.getMessage())?

I want it to print something like this:

java.lang.AssertionError: Page is listing a different job
Expected: <true>
     but: was <false>
dialex
  • 2,706
  • 8
  • 44
  • 74

2 Answers2

0

You can use the Build Failure Analyzer Plugin for Jenkins to create some regex and print them on the build page.

It will be a link which jumps to the right line in the log.

enter image description here

CSchulz
  • 10,882
  • 11
  • 60
  • 114
0

Since Jenkins was invoking a gradle build, gradle was absorbing all intermediary outputs, and thus only the results were outputted to the Jenkins console.

This is what I did to solve the issue, on my gradle.build file:

nameOfTaskThatRunsTests {
    testLogging {
        events "standardOut"
    }
}

And on my java test file:

@Rule
public TestRule testWatcher = new TestWatcher() {
    @Override
    public void failed(Throwable t, Description test) {
        if (t instanceof AssertionError) {
            System.out.println("Failed assertion: " + t.getMessage());
        }
    }
};
Community
  • 1
  • 1
dialex
  • 2,706
  • 8
  • 44
  • 74