idea can't distinguish a test case is junit4

hi,all:
     My english is poor. I hope the problem is clearly and properly presented.
     I use idea 10.5.1, when i run a test case, it throw exceptions:
     2011-11-17 17:01:13,724 [] INFO  adboard.AdboardBOTest - ApplicationContext has not been configured for test [com.taobao.ad.zuanshi.biz.bo.adboard.AdboardBOTest]: dependency           injection will NOT be performed.
     2011-11-17 17:01:13,724 [] INFO  adboard.AdboardBOTest - No transaction manager set: test will NOT run within a transaction
     The spring contextConfiguration files are not loaded.
     In the BaseTestCase, i use annotation @ContextConfiguration to load contextConfiguration files.
     @ContextConfiguration(locations={
      "classpath:/springbeans-data-source-test.xml",
      "classpath:/springbeans-rpt-ds-test.xml",
     // "classpath:/ehcache.xml",
      "classpath:/springbeans-web-manager.xml",
      "classpath:/springbeans-dozer-test.xml",
    "classpath:/springbeans-hsf-remote-test.xml",
      "classpath:/springbeans-tbuic-client-test.xml",
      "classpath:/springbeans-web-bo-test.xml",
      "classpath:/springbeans-hsf-remote.xml"
      })

     but, when i delete a import statement "import static org.mockito.Matchers.any;" Everything is OK!!!!!!
     then i occuer the same problem when i add some other import...
     Last, I find when the test case is ok, in consle idea print"com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4  XXX"; when test case isn't ok, in consle idea print"com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 XXX"; so i doubt idea can't  distinguish a test case is junit4 in some case. I can't find the place to set idea alway use junit4.
     I need help!!!!

     
3 comments

Hello,
IDEA detects that you use junit4 when you have junit annotations thought when your test extends TestCase it would be run inside junit as junit3 test case. That is not IDEA's specific but junit itself (we must follow the command line; junit ant, etc).
So if you don't need to extend TestCase - please do not extend it or use additional setUp/tearDown methods to correctly inject everything.
Thank you

0

I want to know why i delete the import statement "import static org.mockito.Matchers.any;" everything is ok:|
And i can't confirm which import can cause that problem.......

0

Sorry, I do not understand. The runner is chosen by junit itself anyway. IDEA chooses in both cases junit4 (from parameter in the command line). If it possible please attach your whole test (with superclass dependencies) otherwise it is impossible to detect whats wrong.
Thank you

0

Please sign in to leave a comment.