There was a sensation:
The presentation of the new iPhone went unnoticed!
Because we released Selenide 5.3.1. With improved shots as well. :)
We fixed only one problem in this version, but what problem is it!
Maven, where are my screenshots?
Recently we discovered that users of Maven and latest
maven-surefire-plugin:2.22.2 were deprived of one of the most important selenide features:
screenshot was not added to the error report.
That was unexpected!
How did you even live without it, poor fellows?
Probably that’s why you think you need BDD, Serenity and Allure? Probably you don’t need. :)
See the difference
That’s how error report looks in Maven and latest
com.codeborne.selenide.ex.ListSizeMismatch: : expected: = 11, actual: 0, collection: .results Elements:  at org.selenide.GoogleTest.openGoogle(GoogleTest.java:42)
You don’t see a screenshot. Bad luck.
And this is how error report looks in Gradle, Ant, any IDE and default
List size mismatch. Expected: = 11, actual: 0, collection: .results Elements:  Screenshot: file:/Users/andrei/projects/selenide-examples/sandbox-selenide-junit5/build/reports/tests/1567803355181.0.png Page source: file:/Users/andrei/projects/selenide-examples/sandbox-selenide-junit5/build/reports/tests/1567803355181.0.html Timeout: 4 s. at org.selenide.GoogleTest.openGoogle(GoogleTest.java:42)
Now you see a screenshot in case of test failure. It’s enough to investigate the reason of test failure. You just don’t need any “nice” reports, BDD, report portals etc.
Now we are talking!
But why it happened?
- In Java, there is a class
Throwablewhich is a parent of all errors and exceptions.
- It has 2 important methods:
- by default
For example, the following code
Throwable e = new IllegalArgumentException("nope"); System.out.println(e.getMessage()); System.out.println(e.toString());
nope java.lang.IllegalArgumentException: nope
Initially, Selenide added screenshot name in method
And it worked fine in Gradle, Ant, all IDEs. And in Maven too - in case of default
So what was updated in Maven?
There are funny guys working on Maven.
- Maven has 2 plugins for tests, not one.
- These plugins are named “surefire”, not “test” (which would be intuitive and clear for everyone)
- The latest Maven 3.6.2 by default uses different versions of those plugins:
maven-surefire-plugin:2.12.4- 7 years old (e.g. doesn’t support Java 11)
- and unexpectedly
maven-surefire-report-plugin:3.0.0-M3- beta version, not ready for production
Now, if you upgrade to latest
maven-surefire-plugin in your pom.xml:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> </plugin>
test reports start changing. Instead of
e.toString() it now uses
class name + getMessage().
That’s why screenshots are not appended to error report anymore.
How we fixed it?
Simple. We now add screenshot in method
e.getMessage() instead of
Sound simple, but we had to refactor all Selenide exceptions and fix many tests.
Probably something went wrong, so feel free to file issues, if you wish some error messages to be improved!
All the background and code modifications can be found here:
Selenide goes over the world!
- Look, what a great video created Martin Škarbala from Slovakia. In just a 1.5 minutes he demonstrates benefits of Selenide, and how much of boilerplate code you can delete after migration to Selenide.
- September, 20-21 - I will give two talks at QA Fest conference - Kyiv, Ukraine