简体   繁体   English

如何通过Maven创建运行配置以运行junit测试?

[英]How do I create run configurations for running junit tests via maven?

I have an app in which the junit tests should be run via a maven command like this : 我有一个应用程序,其中应该通过这样的maven命令运行junit测试:

mvn test -Dtest=MyCodeTestClassJavaName -Dbase_url=https://myapp-test-environment.com

I can run this via commandline, but I cannot do it in eclipse. 我可以通过命令行运行它,但是我不能在Eclipse中运行它。 Could someone please show me how to do it in eclipse ? 有人可以告诉我如何在日食中做到吗?

Thanks ! 谢谢 !

You need to pass "test" and "base_url" as environment variables in Eclipse. 您需要在Eclipse中将"test""base_url"作为环境变量传递。 Here's docs how to do it. 这是文档操作方法。

在此处输入图片说明

I tried it myself and made it work. 我自己尝试过并使其起作用。 Here is the answer : 这是答案:

1 - Create a maven build configuration. 1-创建一个Maven构建配置。 Refer the image. 请参考图片。 在此处输入图片说明

2 - Base directory = your project root. 2-基本目录=您的项目根目录。

3 - Goal = test 3-目标=测试

4 - Add the parameters in your maven command, that is : 4-在您的maven命令中添加参数,即:

test = MyCodeTestClassJavaName
base_url = https://myapp-test-environment.com

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

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