junit

After a junit test case ran, should I delete the test data related with this test case?

After a junit test case ran, should delete test data related with this test case? Will keeping the test data help the developers to debug the code? Thanks Joseph ...

Managing test data for Junit tests.

Hi, We are facing one problem in managing test data(xmls which is used to create mock objects). The data which we have currently has been evolved over a long period of time. Each time we add a new functionality or test case we add new data to test that functionality. Now, the problem is when the business requirement changes the ...

starting and stopping hsqldb from unit tests

I'm trying to create integration tests using hsqldb in an in memory mode. At the moment, I have to start the hsqldb server from the command line before running the unit tests. I would like to be able to be able to control the hsqldb server from my integration tests. I can't seem to get this to all work out though from code. Thanks, Case...

Unit Testing XML independent of physical XML file

Hi, My question is: In JUnit, How do I setup xml data for my System Under Test(SUT) without making the SUT read from an XML file physically stored on the file system Background: I am given a XML file which contains rules for creation of an invoice. My job is to convert these rules from XMl to Java Objects e.g. If there is a tag as be...

Does JUnit 3 have something analogous to @BeforeClass?

I'm forced to use JUnit 3 for a particular test suite. I understand setUp() and tearDown() serve the function of @Before and @After, but is there an analogue of @BeforeClass and @AfterClass for things that should happen once before the tests start, and once after all tests are run? ...

maven junit pom.xml

Hi, i have a following problem. I'd like ti test my JSF Application with JSFUnit.But JSFUnit supports inly junit3 (all our unit tests run with JUnit4). Is it possible to include in pom.xml two junit dependencies (junit4 and junit3) with e.g. different scopes? Please help and thanx in advance ...

Eclipse JUnit @Before annotation problem

Hello, I'm experiencing some difficulties using JUnit 4.5 in Eclipse, when I use @Before annotation it just does nothing (I may use setUp() which works of course, but I'm just wondering what is wrong), while it works perfectly in Netbeans.. Any thoughts? ...

Passing information between test methods in a junit testcase

Hi, Currently I am creating a TestCase for one work flow and a workflow have different steps. The results of one step is important since , second step needs to know value of step1's execution. class TestCaseWorkFlow1 extends TestCase { private static String resultOfStep1 = null; public void testStep1(){ if(failed){ r...

JPA DAO integration test not throwing exception when duplicate object saved?

I am in the process of unit testing a DAO built with Spring/JPA and Hibernate as the provider. Prior to running the test, DBUnit inserted a User record with username "poweruser" -- username is the primary key in the users table. Here is the integration test method: @Test @ExpectedException(EntityExistsException.class) public void save...

unit testing with junit4

how do i create a test suite in junit4 ?? ...

Are JPA / Hibernate Exceptions not translated?

I finished a battery of DAO integration tests using JPA/Hibernate and many of them expect exceptions to be thrown. However, I have noticed that Hibernate seems to ignore the nice heirarchy of exceptions provided by the JPA spec and instead always throws the generic PersistenceException that wraps their Hibernate specific exception. Am ...

How do you change the layout of JUnit Reports in Hudson?

So, I'm setting up Hudson right now and couldn't be more pleased. However, I need to display a table in the test results page as opposed to the graph it provides. Does anyone know how I would go about doing this? ...

Using JUnit with App Engine and Eclipse

I am having trouble setting up JUnit with App Engine in Eclipse. I have JUnit set up correctly, that is, I can run tests that don't involve the datastore or other services. However, when I try to use the datastore in my tests they fail. The code I am trying right now is from the App Engine site (see below): http://code.google.com/appen...

Need to use Unit testing famework for testing J2EE Components like Servlets , Filters and JPA.

I need to create unit tests for J2EE components like Servlets, Filters and JPA code which would call it's life cycle methods automatically and would integrate with Maven2 and Continuum and can be run from IDE itself. Can you suggest something? Thanks, Vaibhav ...

What is the best way to launch HSQLDB for unit testing, when working with spring, maven and hibernate?

In my project I can successfully test database code. I'm using Spring, Hibernate, HSQLDB, JUnit and Maven. The catch is that currently I have to launch HSQLDB manually prior to running the tests. What is the best way to automate the launching of HSQLDB with the technologies being used? ...

JUnit @Rule to pass parameter to test

I'd like to create @Rule to be able to do something like this @Test public void testValidationDefault(int i) throws Throwable {..} Where i is parameter passed to the test by @Rule. However I do get java.lang.Exception: Method testValidationDefault should have no parameters is there any way to bypass it and set the i parameter in t...

Does JUnit 3 have something analogous to @Ignore

I'm forced to use JUnit 3. If I were using JUnit 4, I would occasionally use @Ignore since several of my tests take a bit of time. Is there anything analogous in JUnit 4? Commenting out tests is sloppy, and changing the name (from testXxx()) could lead to forgotten tests. @Ignore is great, because it always reminds you which tests we...

Junit Dynamically Created Tests Not Working

Hey, so heres my code: public class NewTest extends SeleneseTestCase { public static Test suite() throws Exception { TestSuite suite = new TestSuite(); TestSuite s = new TestSuite("TestCase Name"); GeneratedTest t = new GeneratedTest("testName"); t.setFailure("TestCase Name: testName"); s.addTest(t); t = ...

JUnit Exception Testing

Edit: Not JUnit 4 available at this time. Hi there, I have a question about "smart" exception testing with JUnit. At this time, I do it like this: public void testGet() { SoundFileManager sfm = new SoundFileManager(); // Test adding a sound file and then getting it by id and name. try { SoundFile add...

EasyMock object for unit testing involving scope="request" bean

I am trying to add some Unit Testing to some of our companies code. Yes, I know it should already be there, but not everyone seems to have the same view of unit testing that I do. However, I have come against a bit of a stopper for me. Admittedly, my Java, Spring and Unit Testing knowledge are not all that they should be. My problem ...