英文:
Maven test not running cucumber tests
问题
在我的示范 Spring Boot 安全项目中,我想要添加一些 BDD 测试。我已经添加了依赖,特性文件,步骤定义等等,但是 mvn test
却忽略了我所有的测试类。
我有一些 JUnit 和 Selenium 测试,它们都能正常运行。
项目是公开的,链接在 https://gitlab.com/vivart/spring-boot-security。为了让问题更简单,我已经移除了所有的 JUnit 和 Selenium 测试。
注意:我已经尝试了所有类似的问题建议。
英文:
In my sample spring boot security project I want to add some BDD tests. I have added dependencies, feature file, sep definition etc. but mvn test
ignoring all my test classes.
I have some junit and selenium tests which are running fine.
Project is public https://gitlab.com/vivart/spring-boot-security to make it more simple I have removed all junit and selenium test.
Note: I have already tried all similar question suggestions.
答案1
得分: 1
我已经完成了2个修改并且能够运行测试:
1: 场景关键字在您的功能文件中丢失。而是您已经给出了Login:
Feature: 登录
Scenario: 登录功能
2: CucumberTestContextConfiguration
类缺失。请将它添加到您的 src/test/java
中,如下所示:
package com.example.auth;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import io.cucumber.spring.CucumberContextConfiguration;
@CucumberContextConfiguration
@SpringBootTest
@AutoConfigureMockMvc
public class CucumberTestContextConfiguration {
}
英文:
I ahve done 2 modificatuons and able to run test:
1: Scenario keyword is missing in your feature file. Instead you have given Login:
Feature: Login
Scenario: Login functionality
2: CucumberTestContextConfiguration
class is missing. Please add it to your src/test/java
like below:
package com.example.auth;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import io.cucumber.spring.CucumberContextConfiguration;
@CucumberContextConfiguration
@SpringBootTest
@AutoConfigureMockMvc
public class CucumberTestContextConfiguration {
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论