junit

How to change JUnit transformation in Maven2

Hi, I have Java project built with Maven2. There is used JUnit framework for testing ( and Selenium but it is irrelevant ). I would like to add screenshot ( I have it ) into result of tests. Here, on SO, I found similar question which solves it but with Ant. I would like to know if there is any option how to manage it with Maven2 instea...

Reporting on test scenarios for a non-technical audience ?

I have (jUnit) unit tests. My project manager would like a human-friendly list of test cases and scenarios (think: a spreadsheet or report for general distribution to a less technical audience). What is an effective way to bridge this gap? ...

Is there a tool for Java which finds which lines of code are tested by specific JUnit tests?

Is there a tool for Java which, given a set of JUnit tests, and a class to test, will tell you which lines of the class are tested by the tests? ie. required to be present for the tests to run successfully. I don't mean "code coverage", which only tells you whether a line is executed, but something stronger than that: Is the line requi...

How do I run JUnit tests during my Ant build script while omitting test classes from my resulting jar?

I'm using the Hello World with Ant tutorial from the Ant manual to learn about Ant. The last part of the tutorial involves adding JUnit tests to the project. I've got everything working as described in the tutorial and am now going on to make some minor changes. One of the changes I would like to make is to run the tests during a typi...

Spring 3+ How to create a TestSuite when JUnit is not recognizing it

I'm using Spring 3.0.4 and JUnit 4.5. My test classes currently uses Spring's annotation test support with the following syntax: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration (locations = { "classpath:configTest.xml" }) @TransactionConfiguration (transactionManager = "txManager", defaultRollback = true) @Transactional pu...

Cobertura showing 0% coverage

Hi folks, I'm using Cobertura 1.9.3 with NetBeans 6.8, Ant 1.7.1 and JDK 1.6.0_21 running with -WAR, and EJB, JUnit 4 tests. When I change the line "pathelement location="${build.classes.dir}" /" to "pathelement location="${build.test.classes.dir}" /", there is some coverage (albeit in the wrong classes, it shouldn't be in the testclas...

How to run test methods in spec order in JUnit4?

I want to execute test methods which are annotated by @Test in spec order. For example: public class MyTest{ @Test public void test1(){} @Test public void test2(){} } I want to ensure to run test1() before test2() each time I run MyTest, but I couldn't find annotation like @Test(order=xx). I think it's quite important featur...

Classpath problem for my Ant Build file

I have been using this exact Build.xml file. I had problems in the beginning using the junit task with it, but I figured out those problems a couple months ago. Recently I got the all to common error message when I ran my build file with the test task. test: [junit] Testsuite: com.mmz.mvc.test.AgentDAOTest [junit] Tests run: 1, Failure...

How to mock the view in the MVC integration testing using JUnit and EasyMock

Hi, I would like to mock a view implementation of the MVC design pattern. I have implemented the MVP(another MVC variation), and would like to test if the certain methods in the view get called correctly by the controller when a state change happens on the model. The following shows the sequence of method calls on the model, controller ...

Is Assert-ing on tearDown (@After) method wrong?

I have multiple test cases even and if the logic is different, the output must be equal on all of them. So I was thinking in how to generalize them and place the Assert method only once. Is there any way better to do it than this one: static public class Tests() { private static String expected = null; private String actual = ...

Is there a JUnit library/utility to detect the presence of a library?

We're using a few libraries that include an xml parser library through maven. We think we've excluded most of those as we are using a newer version. Is there some sort of JUnit library to check an ear/war for the presence of that jar and fail the test if its there? Or do we just need to write some code to unzip the archive and loop ov...

Noob question about junit

I know this question is not a hard one. I want to implements jUnit on a small project I'm working on because I want to learn a little bit about it. The tutorials that I read all make reference to method that have a particular output. In my case my output are files, how can I do this? any simple example? any aproach that could help me ...

Java get thread created by calling main

Hello! I have a client server application and for testing purposes I need to start the client in a test method by calling Client.main(); That creates some new thread. Now I need to wait until that thread is completed before performing assertions in my test. How do I know when this happens? Alternatively, how do I know, which thread wa...

how to test w/ junit that warning was logged w/ log4j?

I'm testing a method that logs warnings when something went wrong and returns null. something like: private static final Logger log = Logger.getLogger(Clazz.class.getName()); .... if (file == null || !file.exists()) { // if File not found log.warn("File not found: "+file.toString()); } else if (!file.canWrite()) { // if file is ...

Hudson + JUnit + embedded GlassFish, how to provide domain configuration?

I'm using NetBeans and GlassFish 3.0.1 to create an EJB3 application. I have written a few Unit Tests, which get run via JUnit and make use of the embedded GlassFish. Whenever I run these tests on my development machine (so from within NetBeans), it's all good. Now I would like to let Hudson do those tests. At the moment it is failing w...

Grails test-app: How can I disable junitreport?

Hello, I am trying to run some unit tests for my grails app, via "grails test-app -unit". This works as expected. However, when the tests are done, junitreport takes way too long to generate the HTML results, eg: [junitreport] Transform time: 33294ms 33 seconds (on top of the rest of the time) is ridiculous when I want to rapidly mak...

How to distribute junit tests to another machine

The build.xml we have today have many targets to compile and run unit tests. The build.xml refers to many property files with relative to itself. All this works fine when build and test is done on same machine. It is pretty simple to do build get all jars and any test input files to a build_home(another machine). How to run junit on...

Can't load ResourceBundle during junit test

I'm trying to write some Junit tests to test old classes in our app. The code is trying to load a ResourceBundle (for translations) but fails. I guess the problem is classpath related but I can't figure it out. The code is laid out in /src and my tests are in /test. The ResourceBundles are loaded given a base name relative to /src, say,...

How do I run the test cases in a non-web-project I have imported into my Spring web project?

This package has a class - HowToUseGeocell.java - with test cases defined. I have imported this entire project into a larger Java web project (Spring 3) in Eclipse controlled by a Maven task (gae:run). But I don't know how to run these test cases from inside the larger project. Could someone point me in the right direction please? Tha...

Including jMock 2.6.0 in Maven

Hi, I am unable to include the new jMock release as Maven dependency. Here is what I tried including: <dependency> <groupId>org.jmock</groupId> <artifactId>jmock</artifactId> <version>2.6.0</version> </dependency> I have tried various combinations with the version and artifactId but it doesn't help. Thanks, Julia. ...