在Eclipse下使用Maven运行JUnit测试 [英] Running JUnit tests with Maven under Eclipse
问题描述
我写了一个简单的JUnit(版本4)测试。我可以从Eclipse运行它,但不能从pom.xml(alt-click,Run as,Maven Test)运行它。我想我需要告诉Maven搜索该类,但是我不知道如何。
此外,我找不到groupId中的JUnit 4 junit:只有3.8.1版本可用。我真的需要为3.x版而不是版本4 +编写测试?
如何解决?
想想我是Maven的新手,那就是我正在做的事情。所以请不要说工艺技巧,除非我正确地说明我需要做什么。我几乎没有安装Guava作为依赖,现在我完全失去了这些概念。
谢谢!
你可以用Maven运行Junit 4。你只需要你的pom中的Junit 4依赖。
您还需要surefire插件来执行测试。
请参阅: http://maven.apache.org/plugins/maven-surefire-plugin/
提示:默认情况下,surefire将查找具有 * Test.java
命名以查找测试的文件。
I just installed the plugin m2e for the first time on Eclipse.
I wrote a simple JUnit (version 4) test. I can run it from Eclipse, but not from the pom.xml (alt-click, Run as, Maven Test). I suppose I need to tell Maven to search for that class, but I just don't know how.
Also, I couldn't find JUnit 4 in the groupId "junit": only the version 3.8.1 is available. Do I really need to write tests for version 3.x and not version 4+?
How to fix this?
Think of me as a newbie with Maven: that's exactly what I am. So please don't speak about artifact technobabble unless describing exactly what I need to do. I could barely install Guava as dependency and I'm completely lost right now with these concepts.
Thanks!
you can run Junit 4 with Maven. You just need the Junit 4 dependency in your pom. You also need the surefire plugin to execute the tests.
See: http://maven.apache.org/plugins/maven-surefire-plugin/
Hint: By default surefire looks for files with *Test.java
naming to find tests.
这篇关于在Eclipse下使用Maven运行JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!