TIL 3: Dependabot, GreenMail and Selenide JUnit5 extensions

Aliaksandr Rasolka
3 min readMay 18, 2018
  1. GitHub Dependabot keeps up-to-date your project dependencies.
  2. JUnit5 extensions: GreenMail and Selenide
“Cappuccino in a brown mug on a brown saucer with heart foam art on a wooden table” by Jonas Jacobsson on Unsplash

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.

Just an pull request example

You can also use a lot of commands for manage behavior — here is a list of:

Bot command list

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:

JUnit4 soft asserts 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:

JUnit5 soft asserts extension

As you can see — I’ve made some changes across original rule:

  1. 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:

JUnit5 soft asserts extension test

And check test console output:

Catch all fails

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:

--

--