首页 > 解决方案 > java8-cucumber-java8 sprinboot 应用程序

问题描述

我正在尝试从 java 主应用程序运行 .feature,或者说是一个 Spring Boot 应用程序,而不是通过 Junit 方法。我面临从 main 运行它的问题。不知何故,我试图通过在 Eclipse 中使用 Main.main 调用从 main 运行,但是当我打包到 .jar 或部署到 openshift 时,它开始抛出 No backend module found 异常。你们中的任何人都可以帮我找到解决方法吗?我正在使用 java8 和 cucumber-java8 依赖项

例如

Main.main(new String[] { "-g", "com.test.helloworld", "C:\\Users\\<user.name>\\git1\\test-helloworld\\src\\main\\resources\\helloworld.feature" });

我想用普通的java主类试试这个。在 Eclipse 中,它可以毫无困难地执行,但是当我尝试使用 jar/openshift 时,它无法加载功能或后端模块。

标签: cucumber-java

解决方案


SpringBoot 使用嵌套的 jar 结构,需要使用ApplicationContext.getResources才能透明地访问它。因此,您必须为 Cucumber 实现一个利用应用程序上下文的资源加载器。

也可以看看:


推荐阅读