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.

Move MockWebServer TestRule implementation

See original GitHub issue

MockWebServer currently implements TestRule. It is probably better to have a separate MockWebServerRule. This would allow developers to use MockWebServer without the junit dependency.

Optionally, MockWebServerRule could be moved in to a mockwebserver-junit package for all junit-related functionality.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
jodastephencommented, Aug 19, 2016

Just to note that we use TestNG, so having MockWebServer pull in junit is a pain.

This doesn’t have to wait until OkHttp 4 though. A new class MockWebServerLight could be added that did not have the dependency, and the pom.xml could be changed to declare the junit dependency as optional. Even if the pom.xml part was considered too risky, at least end users could exclude it in their pom.

4reactions
detouchedcommented, May 15, 2018

Similarly with JUnit 5: MockWebServer pulls in JUnit 4 which is undesirable, so a standalone version would be very useful.

Ugly but functioning workaround for now is to create a fake empty org.junit.rules.ExternalResource class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integrating MockWebServer into production project's UI tests
As you can see I use MockModelWrapper set and pass it to MockDispatcher in test rule's constructor. As you can see it's a...
Read more >
Migrating From JUnit 4 to JUnit 5: A Definitive Guide
Learn how to migrate from JUnit 4 to JUnit 5. See how to run existing tests along with the new version, and what...
Read more >
Integration Testing with MockWebServer - Industrial Logic
MockWebServer Dependencies. To use MockWebServer, you need two dependencies. Shown below as Gradle imports: testImplementation 'com.squareup.
Read more >
Testing - Spring
Test classes that use the TestContext framework do not need to extend any particular class or implement a specific interface to configure their ......
Read more >
Testing HTTP applications with a few ok libraries — part 2
We can improve this a little bit by using a JUnit test rule. The implementation of a rule is basically a before() and...
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