简体   繁体   English

使用 maven 运行 Fitnesse 测试

[英]Running Fitnesse Tests with maven

I created JUnit -tests for my Fitnesse testcases:我为我的 Fitnesse 测试用例创建了JUnit -tests:

import org.junit.runner.RunWith;
import fitnesse.junit.FitNesseRunner;
@RunWith(FitNesseRunner.class)
@FitNesseRunner.Suite("mysuite")
@FitNesseRunner.FitnesseDir(".")
@FitNesseRunner.OutputDir("./target/fitnesse-results")
public class RunFitnesseTestMySuite {
}

Now I can execute this test like a normal JUnit testcase in Eclipse.现在我可以像 Eclipse 中的普通JUnit测试用例一样执行这个测试。

However, maven completly ignores this test.然而, maven完全忽略了这个测试。 All my other JUnit s are executed by maven but not this particular Fitnesse test.我所有的其他JUnit都是由 maven 执行的,但不是这个特定的Fitnesse测试。

This seems strange to me because @RunWith is a normal JUnit annotation and so I would expect maven to also run these tests.这对我来说似乎很奇怪,因为@RunWith是一个普通的JUnit注释,所以我希望 maven 也能运行这些测试。

Any ideas?有任何想法吗?

You probably have not configured surefire to run tests with a non-default name.您可能还没有配置 surefire 以使用非默认名称运行测试。 Your test class does not match surefire's defaults and therefore will only be run if you configure the tests to run explicitly.您的测试类与 surefire 的默认值不匹配,因此只有在您将测试配置为显式运行时才会运行。 From surefire documentation :surefire文档

By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:默认情况下,Surefire 插件将自动包含所有具有以下通配符模式的测试类:

  • "**/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test". “**/Test*.java” - 包括其所有子目录和所有以“Test”开头的 Java 文件名。
  • "**/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test". “**/*Test.java” - 包括其所有子目录和所有以“Test”结尾的 Java 文件名。
  • "**/*Tests.java" - includes all of its subdirectories and all Java filenames that end with "Tests". “**/*Tests.java” - 包括其所有子目录和所有以“Tests”结尾的 Java 文件名。
  • "**/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase". “**/*TestCase.java” - 包括其所有子目录和所有以“TestCase”结尾的 Java 文件名。

If the test classes do not follow any of these naming conventions, then configure Surefire Plugin and specify the tests you want to include.如果测试类不遵循任何这些命名约定,则配置 Surefire 插件并指定要包含的测试。

In your case I expect you want to use something like:在你的情况下,我希望你想使用类似的东西:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.21.0</version>
        <configuration>
          <includes>
            <include>**/*Suite.java</include>
          </includes>
        </configuration>
      </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM