question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

compatibility with JUnit TestRule ?

See original GitHub issue

Is it possible to provide compatibility with JUnit TestRule ? Several frameworks provide test utilities as TestRules, to be used with @Rule or @ClassRule (exemple : DropWizard’s ResourceTestRule or DropwizardClientRule). Unless there is a way to import or bridge with these TestRules, fully switching to kotlintest is not convenient.

Thanks for the nice work,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
pakoitocommented, Nov 25, 2017

I have a legitimate use case for supporting @Rule. The Android framework and its helper libraries rely on it for test behavior.

One example is the just released architecture-components: https://github.com/googlesamples/android-architecture-components/blob/master/GithubBrowserSample/app/src/test/java/com/android/example/github/ui/user/UserViewModelTest.java#L55

Without that rule it’s impossible to unitest that library, as it tries to find a Thread that doesn’t exist outside Android environments, and fails with NPE.

Read more comments on GitHub >

github_iconTop Results From Across the Web

compatibility with JUnit TestRule ? · Issue #190 - GitHub
Is it possible to provide compatibility with JUnit TestRule ? Several frameworks provide test utilities as TestRules, to be used with @Rule ...
Read more >
Guide to JUnit 4 Rules - Baeldung
Learn how to use the JUnit 4 Rules Model to extend the behavior of JUnit ... This annotation works very similarly to @Rule...
Read more >
Effectively Manage Your Test Cases with JUnit Rules - Medium
JUnit rules is a useful feature to manage the JUnit test cases. ... JUnit rule works based on the principles of Aspect-Oriented Programming ......
Read more >
Junit @Rule and @ClassRule - java - Stack Overflow
I am writing JUnit4 test in which I am using TemporaryFolder rule. It seems that it works fine with both @Rule and @ClassRule....
Read more >
JUnit4 rules with AndroidX Test - Android Developers
JUnit rules provide more flexibility and reduce the boilerplate code required in tests. For example, they can be used to start a specific...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found