如何为 Maven 测试配置 .gitlab-ci.yml

问题描述 投票:0回答:2

我是 GitLab 的新手。我有一些测试,我想通过 CI\CD 运行它们。你能帮我配置我的 .yml 吗? 我应该运行 testng.xml

这是我的项目: enter image description here

我的测试路径是:

src/test/java/tests/"files with tests"

我的 .yml 文件:

image: maven:3-jdk-7

build:
  script: mvn install -b
maven testing automation gitlab-ci gitlab-ci-runner
2个回答
1
投票
test:
  image: xxxx/xxx-test:latest
  stage: test
  script:
    - pwd
    - mvn test

0
投票

首先,尝试在 cmd 或 PowerShell 中打开您的测试路径并执行“mvn test”。这将通知您是否可以使用 maven 命令在该路径上运行测试。

要在 .yml 文件中使用它,您可以执行以下操作:

test_stage:
 stage: test
 tags:
  - TAGNAME_OF_YOUR_CONFIGURED_GITLAB_RUNNER
 script:
  - Start-Process powershell.exe -ArgumentList "-Command cd C:\PATH_TO_YOUR_SCRIPTS_WHICH_IS_SRC_FOLDER && mvn test " -NoNewWindow

在脚本中,您将打开一个 PowerShell 窗口,导航到您的测试文件夹,并在那里进行 mvn 测试。

© www.soinside.com 2019 - 2024. All rights reserved.