黄瓜-如何在每个场景之间自动重新创建Spring bean?

在一个场景之后,我的测试上下文(使用弹簧注释@Component并通过@Autowired连接到我的步骤)很脏,我希望它自动重置,以便接下来的场景在开始之前具有一个干净的上下文。 / p>

我可以使用黄瓜注释@ Before / @ After手动进行此操作,但是它将显示在报告中,但我不希望这样做,因为它没有任何商业价值。


亚军课

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/features",glue = "com.company.steps",tags = "@smoke",plugin = {"pretty","json:target/cucumber-report/cucumber.json","html:target/cucumber-report/html"})
public class RunCucumber {
}

cucumber.xml(弹簧配置文件)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.funky.company"/>

</beans>

黄瓜:4.8.0

春季:5.2.0.RELEASE

Junit :4.12

yychuan123456 回答:黄瓜-如何在每个场景之间自动重新创建Spring bean?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3145412.html

大家都在问