Maven测试未运行cucumber测试。

huangapple go评论79阅读模式
英文:

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 {

}

huangapple
  • 本文由 发表于 2020年8月31日 20:07:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63670521.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定