nickylin / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Tests Classes cannot inherit another class if we want to use @PowerMockRunnerDelegate with a runner that extends ParentRunner #530

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a test class (MyTest.java) that inherits another one 
(MyAbstractTestClass.java)
2.On MyTest.java add the annotations @RunWith(PowerMockRunner.class)and 
@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
3.Create a test method in MyTest.java (the method may be empty)
4.Run the test

What is the expected output? What do you see instead?
The expected output is a successfull run, but instead it fails with an 
Exception : java.lang.IllegalArgumentException: Test class can only have one 
constructor

What version of the product are you using? On what operating system?
PowerMock 1.6.0
Mockito 1.10.8
Junit 4.11
Spring 3.1.4
Windows 7 64bits

Please provide any additional information below.
When a testClass inherits another one PowerMock adds a new constructor that 
takes a IndicateReloadClass as parameter. But when we try to instanciate a new 
SpringJUnit4ClassRunner, which extends org.junit.runners.ParentRunner, it tries 
to build a new MyTest, which now has 2 constructors and fails.

Original issue reported on code.google.com by Alex.bel...@gmail.com on 4 Dec 2014 at 9:33

Attachments:

GoogleCodeExporter commented 9 years ago
Any workarounds except of removing base class?

Original comment by selivar...@gmail.com on 18 Feb 2015 at 11:19