Test logs
Logs are still one of the best ways of debugging your software. When it comes to writing log lines, you end up getting lost in the GitHub Actions results. Foresight eases your pain and group tests, test suites along with their logs.
So that you can understand why even the most complex integration test failed, without losing your way on the GitHub Actions.
With the below configurations, you can start displaying your logs on the Foresight.
JUnitโ
Maven Surefire pluginโ
If you are using Maven Surefire to run tests, Foresight automatically captures
the logs <system-out>
and <system-err>
fields in your tests.
Your Surefire version needs to be >=3.0.0-M5.
For more information, please refer:
- https://issues.apache.org/jira/browse/SUREFIRE-1744
- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin
Gradleโ
If you are using Gradle, Foresight automatically captures
the logs <system-out>
and <system-err>
fields in your tests.
You need to have reports
section on your test section.
test {
useJUnitPlatform()
reports {
junitXml {
outputPerTestCase = true // defaults to false
mergeReruns = true // defaults to false
}
}
}
TestNGโ
In addition to your system
logs, if you are using TestNG's test reporter,
Foresight captures:
Reporter.log("LOG_CONTENT")
Jestโ
Foresight can parse JUnit formatted test reports. For Jest framework, you can use jest-junit reporter for generate Junit reports. If you are using Jest, you need to configure your report settings for Foresight to capture your test results.
Set an env variableโ
You need to set the following environment
JEST_JUNIT_INCLUDE_SHORT_CONSOLE_OUTPUT=true
Configuring reporterโ
Add reporter parameter jest-junit
to your Jest configuration or your command.
--reporters="jest-junit"
Your Jest version needs to be >=6.4.0
Pytestโ
Pytest automatically generates a JUnit test report if you add the following to your command.
--junit-xml=reportname.xml
In addition, you need to add the below to enable logging if your Pytest version is >=3.5.0
.
-o junit_logging=all
Example command:
pytest -o junit_logging=all --junit-xml=abc.xml
Trxโ
You can configure ITestOutputHelper for capture test logs help with this guide https://xunit.net/docs/capturing-output
Foresight captures the following outputs from your test report:
<Output>
<StdOut>This is output from my class!</StdOut>
</Output>
XUnit2โ
You can configure ITestOutputHelper for capture test logs help with this guide https://xunit.net/docs/capturing-output
Foresight captures the following outputs from your test report:
<output>This is output from my class MyTest2!</output>