junit

Test data directory with jUnit

I'm writing some jUnit tests that depend on data files. Where should those data files go? And how would I (in the jUnit tests) get the location of that directory? In Python, I would use something similar to: datadir = os.dirname(__file__) + "/data/" ...

JUnit assertion extensions

I'm often creating custom assertion methods for my JUnit tests. eg: public void assertArrays(String[] actual, String[] expected) I was wondering if there were any decent third party libraries that can provide a wider range of assertions than what comes by default in JUnit. Am using JUnit 4. ...

eclipse outOfMemoryError: heap space

Hi, while running junit tests I always seem to run into the above error. I have monitored eclipse with JConsole and heap memory peaks at about 150MB and yet I have set heap memory to 1GB? I am using the following argumments when starting eclipse -vm "C:\Program Files\Java\jre1.5.0_08\bin\javaw.exe" -vmargs -Xmx1024M -XX:MaxPermSize=1...

How to find unit tests not part of any suite?

With JUnit 3, if you forget to add a test to a suite, it will not get run. How can I find all JUnit test cases that are not part of our top level suite, or any suite it recursively contains? ...

Passing JUnit command line parameters in eclipse

I have recently been using junit in eclipse and I am still learning. I know how to pass command line parameters in eclipse, but how do I pass them to a test case in Junit? Also how do I access them? ...

Finishing details on a JUnit 4 dynamic suite

Hi – I wanted to automatically sweep JUnit tests into suites as part of my continuous builds, so I derived a runner from JUnit's Suite which finds all test classes in a package. The runner works just fine, but the results display is less than expected. I have one class in my testing support package with a @RunWith annotation for my runn...

Running a JUnit test from Groovy Console

How can I use the Groovy Console to kick off junit tests? (Currently using Groovy 1.6.0) ...

running junits and cobertura with maven.

...

Why isn't my @BeforeClass method running?

I have the following code: @BeforeClass public static void setUpOnce() throws InterruptedException { fail("LOL"); } And various other methods that are either @Before, @After, @Test or @AfterClass methods. The test doesn't fail on start up as it seems it should. Can someone help me please? I have JUnit 4.5 The me...

externalizing junit stub objects.

Hi!    In my project we created stub files for testing junits in java(factories) itself. However, we have to externalize these stubs. After seeing a number of serializers/deserializers, we settled on using XStream to serialize and deserialize these stub objects. XStream works like a charm. Its pretty good at what it claims to be. Previ...

Spring / Hibernate / JUnit - No Hibernate Session bound to Thread

Hi I'm trying to access the current hibernate session in a test case, and getting the following error: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(S...

Why can't java find the JUnit framework?

Hey everyone, I am trying to get a test class compiling with JUnit, and I can't figure out why it will not compile. I have the following lines at the top of my class: import java.util.*; import org.junit.*; And the error I am getting is package org.junit does not exist JUnit.jar is currently located in Program Files\JUnit\junit.j...

Running the same JUnit test case multiple time with different data.

Is there there any way to tell JUnit to run a specific test case multiple times with different data continuously before going on to the next test case? ...

JUnit test cases- setting up data

I have a simple CRUD operations that needs to be unit tested These test cases are for DAO layer- so all tests are against the database and hence cant be mocked. So I have one test cases for create another for update and another for read. 1) Should I hard code the data in the JUnit class or do you externalize it ? 2) The Read TestCase ...

JUnit: Could not find class

I just installed JUnit but I can't get it to work: C:\tools\junit4.6>java org.junit.runner.JUnitCore org.junit.tests.AllTests. JUnit version 4.6 Could not find class: org.junit.tests.AllTests. Time: 0 OK (0 tests) This are my environment variables: CLASSPATH=.;C:\Program Files\Java\jre1.5.0_11\lib\ext\QTJava.zip;c:\tools\junit4 .6\...

Findbugs filter file for ignoring JUnits

Hi guys, I need to set up a filter file for my findbugs ant script that scans only the src/* files and not the test/* files. What is the syntax for checking all classes while ignoring any filename or package name with 'test' in the name? Thanks ...

Running Nightly Builds as XP Scheduled Task - Classpath Issue

I'm running JUnit nightly builds on my computer as a scheduled task in Windows XP. My application uses Jaxb, therefore some of the tests need to reference xsd schemas using the system classpath. When the nightly build runs while I'm not on the computer, I get an error like this: java.lang.Exception: Unable to load schema mySchema.xsd ...

Cannot run a JUnit test case containing threads from Eclipse

I am running JUnit test case from Eclipse 3.4.1 . This test case creates a class which starts a thread to do some stuff. When the test method ends it seems that Eclipse is forcibly shutting down the thread. If I run the same test from the command line, then the thread runs properly. Somehow I do not remember running into such problems ...

Skipping tests in some modules in Maven

I would like my Maven builds to run most unit tests. But there are unit tests in one project which are slower and I'd like to generally exclude them; and occasionally turn them on. How do I do this? I know about -Dmaven.test.skip=true, but that turns off all unit tests. I also know about skipping integration tests, described here. ...

JUnit Reports -- Test Method Descriptions

Hi, I am trying to see if there is a way to include "descriptive text" in my junit reports by way of javadocs. JUnit 4 doesnt seem to support the 'description' attribute for the @Test annotation like TestNG does. So far from what I have researched there is only one tool out there called javadoc-junit (http://javadoc-junit.sourceforge....