tiebin-zhang / powermock

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

Can't run individual jUnit tests when using PowerMockRunner - Unrooted Tests, caused by NoTestsRemainException always being thrown by filter #375

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

1. Create a Test class annotated with @RunWith(PowerMock.runner)
2. Create 3 test methods annotated with @Test
3. annotate one but not all of these methods with 
@PrepareForTest(SomeClass.class)
4. run jUnit test for class
5. 3 tests run normally, but now select just one of the tests and run that
6. an "Unrooted Tests" item appears in jUnit view, with an 
"initializationError" child.  The test method 

Running individual tests should run the same as when running all tests in a 
class. 

jUnit 4.8.2 , PowerMock 1.4.11 in eclipse 3.7 , Windows 7

This seems to be caused by the TestSuiteChunker breaking up methods into 
separate chunks, then when filter() is called on any chunk which the selected 
method was not in, a NoTestsRemainException is thrown because every method was 
filtered out of that chunk.

The test for throwing this exception should be in the filter method of the 
TestSuiteChunker using getTestCount(), and should only called after all 
delegates have been filtered.

Original issue reported on code.google.com by nic.infa...@gmail.com on 5 Mar 2012 at 3:18

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

This is a known issue but thanks for investigating. Could you help out by 
creating a patch for this?

/Johan

Original comment by johan.ha...@gmail.com on 8 Mar 2012 at 11:14

GoogleCodeExporter commented 9 years ago
I just encountered this issue running Eclipse Luna with PowerMock 1.5.6. I ran 
individual tests before on a different box (both Windows 7 64-bit), but that 
box died so I had to quickly set up another.  On the new one, individual test 
are failing with the unrooted tests initialization error.  Fortunately for me, 
the test I just added and need to test doesn't need PowerMock, so I commented 
out @RunWith and @PrepareForTest, and my one test now runs.

Thanks.

Original comment by guy.roui...@gmail.com on 21 Jan 2015 at 3:35

GoogleCodeExporter commented 9 years ago
I just tried upgrading to PowerMock 1.6.0, same issue occurs.

Original comment by guy.roui...@gmail.com on 21 Jan 2015 at 3:43