[英]Tests are not running in my gitlab-ci pipeline
I know that Tests don't run in gitlab-ci pipeline seems to look like the question I'm trying to ask.我知道测试不在 gitlab-ci 管道中运行似乎看起来像我想问的问题。 However, my .gitlab-ci.yml
and pom.xml
files are almost as generic as you can possibly have them and my tests are not running.但是,我的.gitlab-ci.yml
和pom.xml
文件几乎与您可能拥有的一样通用,而且我的测试没有运行。
My .gitlab-ci.yml
looks like this:我的.gitlab-ci.yml
看起来像这样:
image: maven:3.8.6-openjdk-18-slim
build:
stage: build
script:
- mvn compile
tags:
- shared_runner1
test:
stage: test
script:
- mvn clean test
tags:
- shared_runner1
My pom.xml
looks like this:我的pom.xml
看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>simple-project</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
and the test results look like this:测试结果如下所示:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:00 min
[INFO] Finished at: 2022-09-21T13:39:08Z
[INFO] ------------------------------------------------------------------------
even though I have one class with a test method that is passing.即使我有一个测试方法通过的 class。 May I please know what is going wrong with my setup?请问我的设置出了什么问题?
Problem solved.问题解决了。 My pom file doesn't have the surefire plugin, which when added would make the file look like:我的 pom 文件没有surefire插件,添加后会使文件看起来像:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>comp2120-2022-group-assignment-2</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.