简体   繁体   English

如何为不同环境运行 JUnit 5 测试套件 [micronaut 1.2.5]?

[英]How to run JUnit 5 Test suite for differents environments [micronaut 1.2.5]?

I have 3 differents types of environments: local, staging and integration.我有 3 种不同类型的环境:本地、暂存和集成。 Each of those environments(application-local.yml, application-staging.yml, application-integration.yml) has some own properties for example proxies.每个环境(application-local.yml、application-staging.yml、application-integration.yml)都有一些自己的属性,例如代理。

For every environments i created differents packages: com.myapp.local;对于每个环境,我创建了不同的包: com.myapp.local; com.myapp.staging; com.myapp.staging; com.myapp.integration. com.myapp.integration。 . . Into each packages they are differents tests.在每个包中,它们都是不同的测试。

How can i then write a test suite in micronaut, where a suite run for one package and one specific environment?然后我如何在 micronaut 中编写一个测试套件,其中一个套件针对一个 package 和一个特定环境运行?

Ex: Test Suite 1 run for package com.myapp.local with environment local例如:测试套件 1 运行 package com.myapp.local与环境本地

How can i then write a test suite in micronaut, where a suite run for one package and one specific environment?然后我如何在 micronaut 中编写一个测试套件,其中一个套件针对一个 package 和一个特定环境运行?

It depends on some factors that you haven't described but one piece is that if you only want to run tests for a certain package, if you are using Gradle you can do something like this...这取决于您尚未描述的一些因素,但有一点是,如果您只想对某个 package 运行测试,如果您使用的是 Gradle,您可以执行以下操作...

./gradlew test --tests com.myapp.local.*

To activate different profiles you can use the environment variable MICRONAUT_ENVIRONMENTS and set it to your profile.要激活不同的配置文件,您可以使用环境变量MICRONAUT_ENVIRONMENTS并将其设置为您的配置文件。

I guess you have different tests tasks.我猜你有不同的测试任务。 You can set any variable via gradle by您可以通过 gradle 设置任何变量

systemProperty "micronaut.environments", "local"

in case you want to go further, you can如果你想进一步 go,你可以

includeTestsMatching "com.myapp.local.*"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM