TIL 3: Dependabot,
GreenMail and Selenide JUnit5 extensions
- GitHub Dependabot keeps up-to-date your project dependencies.
- JUnit5 extensions: GreenMail and Selenide
Dependabot — quite simple but extremely useful GitHub extension that allow you to keep your project dependencies up-to-date.
Just app application to you GitHub account and give permission for target repository and set-up pooling interval.
And when some library will update — bot automatically create new pull request with updates.
You can also use a lot of commands for manage behavior — here is a list of:
Next this — it’s JUnit4 rule
to JUnit5 extension
migration. As example I’ll show you Selenide soft asserts rule.
By default Selenide can assert softly only for TestNG or Junit4, but since JUnit5 drop rule support — it’s impossible to use old rule for that.
So, what we have — Junit4 rule:
As we can see in this rule actions applying on before
and after
levels, so let’s find out what we can use from JUnit5.
We also want to apply actions for each test, so let’s implement BeforeEachCallback
and AfterEachCallback
extension endpoints and create an extension:
As you can see — I’ve made some changes across original rule:
- Move
errorCollector
initialization to constructor — it’s linked with extension using, there are 2 way to use extension:
The first one:
@ExtendWith(SoftAssertsExtension.class)
In this case all going flawless without any problems.
And the second one:
@RegisterExtension
SoftAssertsExtension assertsExtension = new SoftAssertsExtension();
And for this case I’ve move initialization to constructor. I’m using it for tests, that’s also have some interesting points. Also in future — it’s will allow to add parameterized constructor and property use it.
2. Add gerErrorCollector
method to test asserts — it needed to check that all errors will collect and throw for current test:
And check test console output:
Perfect!
I’m also add JUnit5 extension for GreenMail and it’s also copy logic from original Junit4 rule.
You take get and try both extensions by links: