The Angles java client allows various Java Test Execution frameworks to take advantage of the Angles Dashboard.
At the moment we provide libraries for the following the following java execution frameworks:
If your own java test execution framework is not in the list, you are able to use the Angles Java client directly by adding the angles-java-core as a dependency.
Please ensure you set the following system variables (e.g. as part of the maven-surefire-plugin):
<systemPropertyVariables>
<angles.enabled>true</angles.enabled>
<angles.url>http://127.0.0.1:3000</angles.url>
<angles.runName>SampleRunName</angles.runName>
<angles.team>SampleTeamName</angles.team>
<angles.component>SampleComponent</angles.component>
<angles.environment>SampleEnvironmentName</angles.environment>
<!-- optional -->
<angles.phase></angles.phase>
</systemPropertyVariables>
A test can attach files to its results: console logs, network HAR files, videos, Playwright traces, page HTML snapshots and images. Angles shows each one on the test (or the step) with a viewer that suits it. The file extension decides how it is shown, so keep the real one: .log/.txt, .json, .har, .webm/.mp4, .zip (shown as a Playwright trace when the name contains "trace"), .html/.htm, .png/.jpg/.jpeg/.gif/.webp. Requires an Angles server with test attachment support.
reporter.fail("Order confirmation", "Order confirmed", "Payment declined", "");
// attach to the step you just reported, e.g. the page as it was when the assertion failed
reporter.attachDataToLastStep(driver.getPageSource().getBytes(StandardCharsets.UTF_8), "page.html");
reporter.attachFileToLastStep(screenshotFile);
// attach to the whole test
reporter.attachFile(new File("target/videos/checkout.webm"));
reporter.attachFile(new File("target/network.har"));
reporter.attachData(consoleLog.getBytes(StandardCharsets.UTF_8), "console.log");
reporter.saveTest();Uploads happen straight away (they only need the build id), so this works in batch mode too. Like storeScreenshot, a failed upload throws an Error.
By default every call to saveTest() sends the test execution to the Angles API straight away. If you'd rather send the whole test run in a single request at the end (e.g. for large runs), you can enable batch mode on the reporter. The build is still created up-front and screenshots are still uploaded individually as the tests run (they need the build id), but the executions are gathered by the reporter until you call saveAllTests().
AnglesReporterInterface reporter = AnglesReporter.getInstance("http://127.0.0.1:3000/rest/api/v1.0/");
reporter.setBatchMode(true);
reporter.startBuild("TestRunName", "Environment", "Team", "Component");
// run your tests as usual: startTest(), storeScreenshot(), pass()/fail() and saveTest()
// saveTest() now stores the executions in the reporter rather than sending them.
// once all tests are done, store all the executions against the build in one request.
reporter.saveAllTests();Note: the TestNG/JUnit5/Cucumber listeners currently report per test; when using batch mode with those, call saveAllTests() yourself once the run is finished.
Add the appender to your log4j2 configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" packages="com.github.angleshq.angles.listeners.log4j2.AnglesLog4j2LogAppender">
<Appenders>
<AnglesLog4j2LogAppender name="AnglesLog4j2LogAppender"/>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="AnglesLog4j2LogAppender"/>
</Root>
</Loggers>
</Configuration>
Please bear in mind that this appender standalone will not be able to push logs to your Angles Dashboard and requires this to be coupled with a test execution framework like JUnit5 or Testng. i.e. This plugin will not create new runs/builds.