- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Cucumber 和 Spring Boot 的新手,我正在开发一个实现 CommandLineRunner 的 Spring Boot 应用程序,并尝试将其与 Cucumber Framework 集成以运行一些测试并创建相应的报告。现在我的 Cucumber 测试用例运行良好,但在运行测试用例之前它会运行我的 Springboot 应用程序 (Application.java)。这是预期的行为还是只是为了运行我的测试。
主要 Spring Boot 类 - Application.java 类:-
/**
* Main Application Class
*/
@SpringBootApplication
public class Application implements CommandLineRunner {
@Override
public void run(String... args) {
@Autowired
private GWMLController gwmlController;
@Autowired
private SmartXmlController mxMLController;
@Autowired
private ReportingController reportingController;
@Autowired
private ComparisionReportController comparisionReportController;
....
...
My busniess logic
}
现在我的 cucumber 类是:-
AbstractDefination.java
package cucumberJava.steps;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringRunner.class)
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@WebAppConfiguration
public class AbstractDefinitions{
public AbstractDefinitions() {
}
}
测试验证:-
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
@ContextConfiguration(classes = {CucumberConfiguration.class})
public class TestValidations extends AbstractDefinitions {
@Autowired
private GWMLController gwmlController;
@Autowired
private SmartXmlController mxMLController;
@Autowired
private ComparisionReportController comparisionReportController;
@Given("^GID map is not empty$")
public void guid_map_is_not_null() throws Throwable {
comparisonResultMap =
comparisionReportController.makeComparisionMappingMap
(comparisonResultMap);
assertFalse(comparisonResultMap.isEmpty());
}
CucumberConfiguration.java
@Configuration
@ComponentScan(basePackages = "au.com.nab.mx")
public class CucumberConfiguration {
}
在我的 build.gradle 中我有:-
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-
test', version: '1.5.4.RELEASE'
compile group: 'net.sf.supercsv', name: 'super-csv', version: '2.4.0'
compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'
compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'
compile group: 'info.cukes', name: 'gherkin', version: '2.12.2'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
testCompile group: 'info.cukes', name: 'cucumber-spring', version: '1.2.5'
testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
}
.功能
功能:Validations.feature
Scenario Outline: COMPARE_COLUMNS
Given GID map is not empty
When <smt> not-null and <gwml> not null
Then <smt> validateEqual <gwml>
@Smoke
Examples:
| smt | gwml |
| **SMT_GUID | **GWML_GUID |
| SMT_BUY_SELL | GWML_BUY_SELL |
现在我的问题是,每当我运行我的应用程序时,它首先运行我的 Application.java,然后运行我的 Cucumber 测试用例。现在我不确定它的预期行为还是我遗漏了某些内容。
问候,维克拉姆·帕塔尼亚
最佳答案
答案是 - 是的,这是使用 SpringRunner.class 和 @SpringBootTest 和 @ContextConfiguration 注释的预期行为。
关于java - 运行使用 Cucumber 实现 CommandLineRunner 的 SpringBoot 应用程序,在运行功能测试用例之前运行主应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45746913/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!