Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么扩展JerseyTest和扩展TestCase会导致找不到测试_Java_Unit Testing_Maven 2_Junit_Jersey - Fatal编程技术网

Java 为什么扩展JerseyTest和扩展TestCase会导致找不到测试

Java 为什么扩展JerseyTest和扩展TestCase会导致找不到测试,java,unit-testing,maven-2,junit,jersey,Java,Unit Testing,Maven 2,Junit,Jersey,我正在尝试让Jersey测试框架正常工作。我们正在使用maven 1.x构建。我已经创建了以下测试用例 public class SomeResourceTest extends JerseyTest { public SomeResourceTest () throws Exception { super(new WebAppDescriptor.Builder(PACKAGE_NAME) .contextPath(

我正在尝试让Jersey测试框架正常工作。我们正在使用maven 1.x构建。我已经创建了以下测试用例

public class SomeResourceTest extends JerseyTest
{
    public SomeResourceTest () throws Exception 
    {
        super(new WebAppDescriptor.Builder(PACKAGE_NAME)
                      .contextPath(PATH).build());
    }    
    @Test
    public void testSomething() 
    {
        Assert.assertEquals(true, true);
    }
}
当我构建时,在SomeResourceTest中找不到任何测试

现在,当我将testcase更改为extend
junit.framework.testcase
时,测试运行得很好


有什么线索可能导致问题吗
JerseyTest
应该扩展
TestCase
,所以我假设这是其他一些配置问题。

您使用的JerseyTest版本是什么?最新版本依赖于JUnit4,不扩展TestCase

另外,您的测试有点混乱。它有@Test,这意味着您正在使用JUnit4,不应该扩展TestCase。但是在您的描述中,听起来您仍然依赖JUnit3.8中的testXXX和TestCase子类约定

有什么线索可能导致问题吗?JerseyTest应该扩展TestCase(…)

Jersey测试框架是这样的,不,它不是

要使用Maven 1.x运行JUnit 4.x测试,您必须:

  • 在依赖项中添加JUnit4.X

  • 在测试类中使用JUnit4TestAdapter:

    /**
     * @return instance of this as Junit test case
     */
    public static junit.framework.Test suite()
    {
        return new JUnit4TestAdapter(MyTestClass.class);
    }
    
  • 使用JDK5+


请参阅。

也许您需要maven的“JerseyTest”插件?您可能希望在此问题中添加junit标记,以便更多的测试人员看到它。这起到了作用,同时将我的Jersey罐子升级到了最新版本。我想我有一些JUnit3.x和motely运动衫系列的组合。谢谢