Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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
黄瓜试验不';t启动Spring启动应用程序_Spring_Cucumber_Cucumber Junit - Fatal编程技术网

黄瓜试验不';t启动Spring启动应用程序

黄瓜试验不';t启动Spring启动应用程序,spring,cucumber,cucumber-junit,Spring,Cucumber,Cucumber Junit,启动Cucumber测试(通过Selenium和integration/rest)时,Spring Boot(测试)应用程序不会自动启动 如何配置Cucumber并启动Spring引导应用程序 我尝试了很多方法。我的档案是: 黄瓜主曲: @RunWith(Cucumber.class) @CucumberOptions(features = "src/test/resources/cucumber_integration_tests") public class Cucumber_Integra

启动Cucumber测试(通过Selenium和integration/rest)时,Spring Boot(测试)应用程序不会自动启动

如何配置Cucumber并启动Spring引导应用程序

我尝试了很多方法。我的档案是:

黄瓜主曲:

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/cucumber_integration_tests")
public class Cucumber_Integration_Test {
}
粘合代码文件类似于:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = Application.class, loader = SpringApplicationContextLoader.class)
@WebAppConfiguration
@IntegrationTest
public class StepDefsIntegrationTest extends SpringIntegrationTest {
    @When("^the client calls /version$")
    public void the_client_issues_GET_version() throws Throwable {
        executeGet("http://localhost:8080/version");
    }
    etc. 
}
在粘合代码文件中启动应用程序的替代方法:

@SpringBootTest( properties = "server.port=8080", classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class wine_Cucumber_Selenium_Steps {
    private WebDriver driver;
    private String baseUrl = "http://localhost";

    private int port = 8080;

    @Given("^I visit the wine cellar home page$")
    public void goToWineCellarHomePage() {
        // Firefox
        // System.setProperty("webdriver.gecko.driver", "K:\\k_schijf\\download_via_firefox\\geckodriver-v0.11.1-win64\\geckodriver.exe");
        // driver = new FirefoxDriver();

        // Chrome
        System.setProperty("webdriver.chrome.driver", "K:\\k_schijf\\download_via_firefox\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        baseUrl += ":" + port;
        driver.navigate().to(baseUrl + "/index.html");
    }
诊断:

  • 我不认为春天是从一个消息开始的
  • 我收到错误消息“ResourceAccessException:获取“”请求时发生I/O错误:连接被拒绝”

您可能希望将@ContextConfiguration与@SpringBootTest注释一起使用。我有一个cucumber测试工作示例

您可能希望使用@ContextConfiguration和@SpringBootTest注释。我有一个很好的例子

谢谢你@ravinikam为我指明了方向。我将进一步试验ContextPath和SpringBootTest的组合

答案是(可能不是最好的)我使用了Cucumber的1.2.4版本,并将此代码添加到Cucumber的运行测试中。成功了

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ContextConfiguration(classes = Application.class, loader = SpringApplicationContextLoader.class)
@WebIntegrationTest
@RunWith(SpringJUnit4ClassRunner.class)
public @interface CucumberStepsDefinition {
}

比尔东给出了另一个想法:看这个简单的例子

谢谢你@ravinikam为我们指明了方向。我将进一步试验ContextPath和SpringBootTest的组合

答案是(可能不是最好的)我使用了Cucumber的1.2.4版本,并将此代码添加到Cucumber的运行测试中。成功了

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ContextConfiguration(classes = Application.class, loader = SpringApplicationContextLoader.class)
@WebIntegrationTest
@RunWith(SpringJUnit4ClassRunner.class)
public @interface CucumberStepsDefinition {
}

比尔东给出了另一个想法:看这个简单的例子

谢谢你分享你的代码。我试图将ContextConfiguration/SpringBoot放在Cucumber运行测试中,但它还不能工作。你有一个Cucumber、Selenium、Spring Boot示例吗?除了Cucumber定义的步骤外,我还添加了带有\@SpringBootTest注释的\@ContextConfiguration,你的解决方案就可以了!!它甚至可以在做黄瓜、硒、春季开机测试时使用!!除了运行测试之外,如果将其放置(仅限),它将不起作用。感谢您共享您的代码。我试图将ContextConfiguration/SpringBoot放在Cucumber运行测试中,但它还不能工作。你有一个Cucumber、Selenium、Spring Boot示例吗?除了Cucumber定义的步骤外,我还添加了带有\@SpringBootTest注释的\@ContextConfiguration,你的解决方案就可以了!!它甚至可以在做黄瓜、硒、春季开机测试时使用!!除了runtest之外,当put(仅)时,它不起作用。