I just solved this one now, when I added the @RunWith(PowerMockRunner.class)
attribute, eclipse
automatically imported:
import org.powermock.modules.junit4.legacy.PowerMockRunner;
All I needed to do is change it to be:
import org.powermock.modules.junit4.PowerMockRunner;
And now it works fine with JUnit 4.8.2
.
The 2nd runner is for when running with older versions of JUnit
– specifically 4.3
and older.
Related Contents:
- How to mock static method without powermock
- How do I test a class that has private methods, fields or inner classes?
- How to verify that a specific method was not called using Mockito?
- Mockito : how to verify method was called on an object created within a method?
- How to use JUnit to test asynchronous processes
- Java: How to test methods that call System.exit()?
- Assert equals between 2 Lists in Junit
- Java verify void method calls n times with Mockito
- How do I assert equality on two classes without an equals method?
- What’s the actual use of ‘fail’ in JUnit test case?
- Using PowerMockito.whenNew() is not getting mocked and original method is called
- Separation of JUnit classes into special test package?
- Multiple RunWith Statements in jUnit
- PowerMockito mock single static method and return object
- annotation to make a private method public only for test classes [duplicate]
- JUnit 4 compare Sets
- Mock a constructor with parameter
- Run single test from a JUnit class using command-line
- assertAll vs multiple assertions in JUnit5
- JUnit test with dynamic number of tests
- AssertEquals 2 Lists ignore order
- How to write junit tests for interfaces?
- Testing a JAX-RS Web Service?
- Easier DynamoDB local testing
- Should the JUnit message state the condition of success or failure?
- EasyMock: Void Methods
- Try catch in a JUnit test
- How to test methods that call System.exit()?
- How to disable entire unit test in TestNG?
- Writing a single unit test for multiple implementations of an interface
- What use is @TestInstance annotation in JUnit 5?
- Why doesn’t this code attempting to use Hamcrest’s hasItems compile?
- Mocking a class vs. mocking its interface
- How to mock new Date() in java using Mockito
- Is it possible to create a mock object that implements multiple interfaces with EasyMock?
- ‘No JUnit tests found’ in Eclipse
- Mocking a singleton with mockito
- What’s the purpose of the JUnit 5 @Nested annotation
- Mock same method with different parameters
- Forming Mockito “grammars”
- Grouping JUnit tests
- Junit Parameterized tests together with Powermock – how?
- Test-Driven Development – How to write a test before none of implementation code exists
- JUnit expected tag not working as expected
- How to assert an actual value against 2 or more expected values?
- How to assert an actual value against 2 or more expected values?
- How can I do unit test for hashCode()?
- PowerMock, mock a static method, THEN call real methods on all other statics
- Misplaced argument matcher detected here. You cannot use argument matchers outside of verification or stubbing in Mockito
- How to use Mockito to show all invocations on a mock