Java 我如何准备大量数据,等待,然后在Cucumber中运行测试?

Java 我如何准备大量数据,等待,然后在Cucumber中运行测试?,java,cucumber,junit4,Java,Cucumber,Junit4,我们有来自资产的消息,这些消息必须经过一个长达1分钟的过程,然后数据才能到达可以测试的地方。我们有1200个测试,所以你可以想象需要多长时间 目前,我们正在使用JUnit4,并在运行程序中使用“@BeforeClass”方法来查找带有注释“@Stager”的所有方法并运行它们。然后我们等待,然后我们运行测试。(到目前为止)效果很好 我们希望使用黄瓜,但是,我们需要它: 阶段数据 等待1或2分钟 运行测试 是否有办法先运行所有“给定”方法,暂停1分钟,然后运行测试? 我们在Surefire中尝试了

我们有来自资产的消息,这些消息必须经过一个长达1分钟的过程,然后数据才能到达可以测试的地方。我们有1200个测试,所以你可以想象需要多长时间

目前,我们正在使用JUnit4,并在运行程序中使用“@BeforeClass”方法来查找带有注释“@Stager”的所有方法并运行它们。然后我们等待,然后我们运行测试。(到目前为止)效果很好

我们希望使用黄瓜,但是,我们需要它:

  • 阶段数据
  • 等待1或2分钟
  • 运行测试
  • 是否有办法先运行所有“给定”方法,暂停1分钟,然后运行测试?

    我们在Surefire中尝试了并行线程,但它似乎有缺陷,我们有1200个测试。坦率地说,这方面的事情太多了。 我们真的不需要并行运行。分段数据运行速度快,测试运行速度快。每次测试之间的停顿是一个停止

    我们会考虑延长黄瓜的种类。也许:

    @RunWith(CucumberStage.class)
    

    有什么东西能做到这一点吗?有什么建议吗?

    我不认为您只能在Cucumber中运行所有给定的步骤,然后再运行其余的步骤。Cucumber将逐个运行所有步骤。

    假设您正在使用maven运行测试

    如果您计划使用cucumber的junit runner,您可以继续使用现有的逻辑在runner的
    BeforeClass
    中设置数据。如果你有一个运行程序,那么就更容易了,否则你需要在插件中设置执行顺序。关于跳过给定方法,您可以向
    surefire或failsafe插件添加属性,并在给定方法中使用该属性

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>                 
                <systemProperties>
                    <property>
                        <name>skipproperty</name>
                        <value>myvaluetest</value>
                    </property>
                </systemProperties>
            </configuration>
    </plugin>
    
    但是如果你还想尝试TestNg,你可以使用maven
    exec插件来运行安装代码。这将使它独立于测试框架。设置与上面相同,只是在POM中添加了exec插件

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
                <id>my-execution</id>
                <phase>process-test-classes</phase>
                   <goals>
                        <goal>java</goal>
                    </goals>
            </execution>
        </executions>
        <configuration>
                <mainClass>runner.ExecuteSetup</mainClass>
                <classpathScope>test</classpathScope>
        </configuration>
    </plugin>
    
    
    org.codehaus.mojo
    execmaven插件
    1.6.0
    我的死刑
    过程测试类
    JAVA
    runner.ExecuteSetup
    测验
    

    ExecuteSetup main()
    方法将包含调用设置代码的现有逻辑。确保添加
    classpathscope
    否则您将得到一个奇怪的
    classnotfoundexception

    测试类中如何使用当前解决方案中的数据?你能提供一个小片段来解释你目前的行为吗。
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
                <id>my-execution</id>
                <phase>process-test-classes</phase>
                   <goals>
                        <goal>java</goal>
                    </goals>
            </execution>
        </executions>
        <configuration>
                <mainClass>runner.ExecuteSetup</mainClass>
                <classpathScope>test</classpathScope>
        </configuration>
    </plugin>