junit

How do I halt Maven when JUnit Fails?

I am running Junit tests from Maven. The ant script has <junit failureproperty="failproperty" errorproperty="errorproperty"> <classpath refid="classpath" /> <test name="${unit-test-suite}" /> <formatter type="brief" usefile="false" /> </junit> <echo> --...

Different Singleton instances with JUnit tests

I have a standalone singleton which successfully passes the test. But with a group of tests this fails since once a singleton is defined it does not allow to reset the instance. Any ideas about how to go about this? ...

Java, Junit - Capture the standard input / Output for use in a unit test

I'm writing integration tests using JUnit to automate the testing of a console based application. The application is homework but this part isn't the homework. I want to automate these tests to be more productive -- I don't want to have to go back and retest already tested parts of the application. (Standard reasons to use Unit tests) ...

How can I make JUnit be quiet?

When I run JUnit tests failures cause very large stack traces that don't really provide much information. I would like to be able to just see the failing assert statement, so that each failure takes up at most 2 or 3 lines, instead of 20. I am not using ANT to call JUnit, but am instead running them from a command line in very large bat...

Example of standalone Apache Qpid (amqp) Junit Test

Does anyone have an example of using Apache Qpid within a standalone junit test. Ideally I want to be able to create a queue on the fly which I can put/get msgs within my test. So I'm not testing QPid within my test, I'll use integration tests for that, however be very useful to test methods handling msgs with having to mock out a load...

How to start and stop an Tomcat container with Java?

I have a Maven project that starts a tomcat container for pre-integration-tests (jUnit Tests). Most of my tests require that the web-application under tests is restarted. So I'd like to restart the Tomcat container before each jUnit test is executed. As for now I use the cargo-maven2-plugin to configure the tomcat container. So, is it...

Testing a method instead of testing a whole file in Netbeans w/ JUnit

I'm using Netbeans 6.8 and the finest-grained way to run my JUnit tests from the IDE appears to be to right-click a class under Test Packages and click Test File In Eclipse it's possible to narrow the scope to testing an individual method in a given test harness. How do I test only one individual test out of a harness in Netbeans? ...

Selenium RC ( Dynamic Id Generation)

Hi I am using Selenium RC in Eclipse and JUnit , how i capture dynamic id , Please answer me soon ...

jUnit ignore @Test methods from base class

Let's say I have a test class called testFixtureA with serveral methods testA, testB, testC, etc, each with @Test annotation. Let's now say I subclass testFixtureA into class called testFixtureAB and I don't overwrite anything. testFixtureAB is empty as for now. When I run tests from testFixtureAB, methods testA, testB and testC are ...

Netbeans: Is it possible to use newer version of JUnit than the bundeled one?

Hello, everyone! Has anyone tried to use a newer version of JUnit in Netbeans? Netbeans currently has 4.5 bundled. Newest is 4.8 or so. Could a newer version of JUnit break compatibility with Netbeans' unit test integration? Or do something else negative? ...

junit test method for getters & setters

I am having many java beans in my project. I need to generate a JUnit Test class for them. The test methods generated using eclipse IDE 3.2 & junit 4.4 for the beans are like... public void testGetName() { // fail("Not yet implemented"); } @Test public void testSetName() { // fail("Not yet implemented"); ...

Running JUnit integration tests from a JSP?

Hello, we need to do some integration testing of some Java classes which we want to run inside a Weblogic server. We have a JUnit test suite that runs a set of Junit test classes, and I would like to know if is a good idea to write a JSP that runs the test suite and prints out the results in a graphical way, in case we won't be able to a...

How do you get the python Google App Engine development server (dev_server.py) running for unit test in GWT?

So, I have a GWT client, which interacts with a Python Google App Engine server. The client makes request to server resources, the server responds in JSON. It is simple, no RPC or anything like that. I am using Eclipse to develop my GWT code. I have GWTTestCase test that I would like to run. Unfortunately, I have no idea how to actuall...

Creating a JUnit testsuite with multiple instances of a Parameterized test

I want to create a TestSuite from multiple text files. Each textfile should be one Test and contains the parameters for that test. I have created a Test like: @RunWith(Parameterized.class) public class SimpleTest { private static String testId = "TestCase 1"; private final String parameter; @BeforeClass public static void befor...

DbUnit: problem with increment id generation

I am using DbUnit together with Unitils, which works great most of the time. Today I found a strange problem. Situation is: I use Hibernate, and have id with "increment" generator: <id name="Id"> <generator class="increment"/> </id> I prepare test dataset, where maximal id is 5. I use clean-insert loading strategy. I ha...

Add Spring 3.0.0 java based IOC to JUnit 4.7 tests

There is a doc http://static.springsource.org/spring/docs/2.5.6/reference/testing.html how to add IoC support to junit tests using xml-configuration, but I can not find example for java-based configuration... For example, I have java-based bean: public class AppConfig { @Bean public Test getTest() { return new Test(); } } And...

Testing approach - DB, Junit

Hi All, i would like to ask you about writting tests which are connected with data from database. In my opinion the best way is to have a diffrent DB schema with correct data only for unit testing. In test code i can load the object on the base of ID. The second possiblity is to putting data into database during the unit test. I dont l...

How to run Junit testcases from command line?

I would like to run junit test cases from commandline. Im using eclipse ...

How Can I test Servlets with JUnit?

I saw Jetty has got and ServletTest class which you can use to test Servlets. tester = new ServletTester(); tester.setContextPath("/"); tester.addServlet(TestServlet.class, "/servlet/*"); ... tester.start(); Do you know if there is something similar in Tomcat? How could I test a servlet? ...

Monitoring Grails performance with Hudson

I'm working on a project where performance is important and I would like to be able to monitor how my changes affect performance over time. Has anyone done this with Hudson before? http://wiki.hudson-ci.org//display/HUDSON/Performance+Plugin This Hudson plugin mentions something about supporting "JUnit format", but I can't find anythin...