tiebin-zhang / powermock

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

setUp-method with @Before annotation executed twice when extending TestCase #356

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create test class extending junit.framework.TestCase
2. Implement setUp-method with @Before annotation

What is the expected output? What do you see instead?
Expected: setUp runs only once per test method. Instead, it runs twice.

What version of the product are you using? On what operating system?
powermock-mockito-1.4.10, junit-4.8.2. Windows 7.

Please provide any additional information below.
The problem seems to be in PowerMockJUnit44MethodRunner.runTestMethod(), where 
"setUp" is invoked if the test class extends from TestCase. In my opinion, 
"setUp" should only be called if the test class extends from TestCase AND setUp 
is not annotated with @Before. In the latter case, setUp has already been 
executed by MethodRoadie.runBefores().

Original issue reported on code.google.com by remo.ma...@gmail.com on 21 Nov 2011 at 12:55

GoogleCodeExporter commented 9 years ago
That sounds reasonable to me. Thanks for reporting. Would be awesome if you can 
help out by providing a patch.

Original comment by johan.ha...@gmail.com on 25 Nov 2011 at 9:42

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 5 Jan 2012 at 8:30