html tool

2015年3月5日星期四

关于Maven对JUint的识别问题

这次的plan是all  testcase 在python和java两个版本运行,首个测试的java问题出现,在改写java后Junit的运行时,发现无法运行测试类,我的定义如下:
public class oppor_test {
      ...
      ...
      @Test
 public void addoppor_Test() throws Exception {

但同一目录下的其他test类都可以,why?测试了一下后来发现是命名问题给为oppor_Test的类名称就可以运行了。
我用的是Junit 4.10 ,在MyEclipse中junit运行是没有问题,看来一定是Maven的问题,google了一下,原来如此啊:
参考:http://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run

---------------------------------
By default Maven uses the following naming conventions when looking for tests to run:
  • Test*
  • *Test
  • *TestCase
Your test class doesn't follow these conventions. You should rename it or configure Maven Surefire Plugin to use another pattern for test classes.
---------------------------------------------
原来却是Maven的小秘密啊:).ok了.默认设置的Test本身包含都ok,Testcase结尾的。
PS:此事顺便想到,自己的命名方式应该同一一下了,不区分语言的区分一下,看来是再详细了解一下Jone 说的 系统匈牙利命名法 的使用了。:)

没有评论:

发表评论