Tag: junit

IntelliJ IDEA与Junit 4.7“! 预计JUnit版本3.8或更高版本:“

当我尝试在IntelliJ IDEA中运行以下testing时,我收到消息: “!!! JUnit版本3.8或更高版本预计:” 应该指出的是,这是我在IntelliJ IDEA 9中开发的一个Android项目。 public class GameScoreUtilTest { @Test public void testCalculateResults() throws Exception { final Game game = new Game(); final Player player1 = new Player(); { final PlayedHole playedHole = new PlayedHole(); playedHole.setScore(1); game.getHoleScoreMap().put(player1, playedHole); } { final PlayedHole playedHole = new PlayedHole(); playedHole.setScore(3); game.getHoleScoreMap().put(player1, playedHole); } final GameResults gameResults […]

在运行集成testing时embeddedMongoDB

我的问题是这个的一个变种。 由于我的Java Web应用程序项目需要大量的读取filter/查询以及与GridFS等工具的接口,所以我正在努力想方设法使用MongoDB。 因此,我正在考虑在集成testing的同时运行MongoDB的embedded式实例。 我希望它自动启动 (对于每个testing或整个套件),为每个testing刷新数据库 ,并在最后closures 。 这些testing可以在开发机器上运行,也可以在CI服务器上运行,所以我的解决scheme也需要是可移植的 。 是否有更多关于MongoDB知识的人能帮助我理解这种方法的可行性,或者可能会提供任何可能帮助我开始的阅读材料? 我也打开其他build议,人们可能会如何处理这个问题…

用Mockitotesting一个新的()调用

我有一个遗留类,其中包含一个new()调用来实例化一个LoginContext(): public class TestedClass { public LoginContext login(String user, String password) { LoginContext lc = new LoginContext("login", callbackHandler); } } 我想用Mockito来testing这个类来模拟LoginContext,因为它需要在实例化之前设置JAAS安全性的东西,但是我不确定如何在不改变login()方法来外部化LoginContext的情况下如何做到这一点。 是否有可能使用Mockito模拟LoginContext类?

testing运行“JUnit 4”没有发现testing

我的Javatesting在Eclipse中运行良好。 但现在,当我从运行菜单中重新启动testing时,我收到以下消息: No tests found with test runner 'JUnit 4' 在.classpath文件中,我有所有的jar文件,并在最后有: <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="bin"/> </classpath> 我怎样才能解决这个错误,并让testing再次运行?

更改参数化testing的名称

在JUnit4中使用参数化testing时,有没有办法设置我自己的自定义testing用例名称? 我想改变默认 – [Test class].runTest[n] – 有意义的。

Hudson支持的JUnit XML格式规范

我有哈德森作为持续集成服务器,我想使用选项“发布JUnittesting结果报告”。 但是我不使用xUnit工具进行testing,而是使用运行testing并以简单格式返回结果的shell脚本。 我正在考虑制作一个脚本,将这些结果转换为JUnit格式。 所以我很有兴趣JUnit文件必须看?

双值的assertEquals的epsilon参数的含义

我有一个关于junit assertEqualstestingdouble值的问题。 阅读API文档我可以看到: @Deprecated public static void assertEquals(double expected, double actual) 已过时。 使用assertEquals(double expected,double actual,double epsilon)来代替 epsilon的价值是什么意思? (Epsilon是希腊字母中的一个字母,对吧?)。 有人可以向我解释如何使用它?

Maven没有findJUnittesting运行

我有一个maven程序,编译得很好。 当我运行mvn test它不会运行任何testing(在TESTs头下说There are no tests to run. )。 我已经用一个超级简单的设置重新创build了这个问题,我将在下面包括以及用-X运行时的输出。 unit testing在eclipse中运行良好(包括默认的junit包,以及包含由maven下载的junit.jar)。 另外mvn test-compile正确地创build了testing类下的类。 我正在使用Maven 3.0.2和java 1.6.0_24在OSX 10.6.7上运行此操作。 这是目录结构: /my_program/pom.xml /my_program/src/main/java/ClassUnderTest.java /my_program/src/test/java/ClassUnderTestTests.java 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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>my_group</groupId> <artifactId>my_program</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>My Program</name> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> […]

如何使用Junittesting工具testingvoid方法?

我只是碰巧实现一个方法void followlink(obj page,obj link) ,它只是添加页面和链接到队列。 我没有试图testing这种方法。 我只想testing在队列中包含从followlink方法收到的页面和链接。 我的testing类已经扩展了TestCase。 那么testing这种方法的最好方法是什么?

在jUnit 4.x之前和之后套件执行挂钩

我正在尝试使用jUnit 4.4来执行testing,并进行一系列的集成testing。 拆卸需要可靠运行。 我在TestNG有其他问题,所以我正在寻找回到jUnit。 在所有testing运行之前和所有testing完成之后,哪些钩子可用于执行? 注意:我们使用maven 2来编译。 我已经尝试过使用Maven的post-integration-test pre-和post-integration-test阶段,但是,如果testing失败,maven会停止并且不会运行post-integration-test ,这没有任何帮助。