junit

Is there a way to "fail fast" for junit with the maven surefire plugin?

I'm currently working on a java project using maven. We use the maven surefire plugin to run our junit suite as part of the build process. Our test suite is rapidly growing, in both coverage and execution time. The execution time is very frustrating and time consuming when you end up waiting ten minutes to find out that a test failed...

How can i run my test cases(which written in junit 3.x and 4.x) using jsp?

I want to run my all test cases which is written in both junit versions(3.x & 4.x) in JSP. if i called that jsp it should run all test cases. pls guide me. thanks for advance. ...

JUnit Tests - what do i test?

If I have a basic accessor method that returns an ArrayList What exactly would i test for it? I am very inexperienced when it comes to testing. ...

JUnit Return int value

My Junit test should check that the number being returned is the same as the list size if my test was as follows would this be coded properly, i feel it isnt because i the last 2 lines are always going to be true? public void testGetTotalPilots() { ArrayList<Pilot> list = new ArrayList<Pilot>(); int size = list.size(); as...

JUnit Test Compiling

Hello, I would like to compile JUnit from windows command line. I have a project that contains many different packages. I can compile and run this project from the command line. However, I have difficulties to compile JUnit class that I have created. My JUnit class imports only my model and uses the methods to ensure that my model is c...

How do you unit test JEE code?

I want to ask for your prefered way to test JEE code? I found only three project, that are trying to help to code unit tests in JEE environment: http://jakarta.apache.org/cactus/ : Last Published: 2009-01-18 http://www.junitee.org/ : Last Release: 2004-12-11 http://ejb3unit.sourceforge.net/ : Last Release: 2008-05-17 So I wonder, ...

JUnit test ends with network connection error

I'm running some JUnit 4 tests in eclipse for my Java project which I know have functioned two days ago without problems. Today, though, I get errors: Could not connect to: : 40212 java.net.SocketException: Network is unreachable at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect...

Hamcrest equal collections

Hello! Is there a matcher in Hamcrest to compare collections for equality? There is contains and containsInAnyOrder but I need equals not bound to concrete collection type. E.g. I cannot compare Arrays.asList and Map.values with Hamcrest equals. Thanks in advance! ...

JUnit Eclipse Plugin?

I feel stupid for not being able to find this, but where is the JUnit plugin for Eclipse? I've included the latest .jar in my buildpath, but I still don't have the option to create a new test case, run test cases with the green/red bar, etc. I need the plugin for this, right? EDIT: I'm using "Eclipse for PHP Developers". So perhaps that...

Java jUnit: Test suite code to run before any test classes

I have a test suite class: @RunWith(Suite.class) @Suite.SuiteClasses({ GameMasterTest.class, PlayerTest.class, }) public class BananaTestSuite { What annotation do I need to use to make a function in this class run before any of the classes containing actual tests? Right now, I'm doing this, and it works, but it's not as read...

Java: Mock testing probably with Mockito

I think I'm not using verify correctly. Here is the test: @Mock GameMaster mockGM; Player pWithMock; @Before public void setUpPlayer() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { pWithMock = new Player(mockGM); } @Test public void mockDump() { pWithMock.testDump(); ...

Level of detail of your unit tests

I wanted to start a discussion about the details that you cover in your unit tests. Do you test major functionalities, that consist of several methods doing one task at once with one test? or maybe you even test automatic properties? Because, for example, I see little value in writing a test that would test only this: public Email ...

Using JMockit to mock autowired interface implementations

We are writing JUnit tests for a class that uses Spring autowiring to inject a dependency which is some instance of an interface. Since the class under test never explicitly instantiates the dependency or has it passed in a constructor, it appears that JMockit doesn't feel obligated to instantiate it either. Up until now we have been us...

JUnit4 in Eclipse

I'm trying to run some JUnit test units in eclipse 3.5, but with no luck at all. JUnit3 works fine. When I create the JUnit4 Test unit, eclipse offers to add the JUnit library to the class-path. I accept, but when i check to see if it was added in the project's properties panel, I can see JUnit4 was added, but no JARS where included. I...

Delay EasyMock verification

I'm using EasyMock to create mock objects for JUnit testing in Java. I create a mock object and pass it to another thread where it expects methods to be called. In the other thread, the calls are enclosed in a try/catch(Throwable) block, so when an unexpected call occurs on the mock and it thus throws AssertionError, that error is caught...

Java Unit Test: Replace a private method under test

Is there any way of replacing the logic within a private method when running a JUnit test? A bit of background: we have some private methods which interact with bundles within an OSGi container. This is not available in the unit test therefore the methods will fail. We have looked at JMockIt but the method replace functionality seems t...

A better way to run lots of Integration Tests using JUnit?

What is the best way run a lot of integration tests using JUnit? I crudely discovered that the code below can run all the tests... but it has a massive flaw. The tearDown() method in each of those classes is not called until they have all been run. public class RunIntegrationTests extends TestSuite { public RunIntegrationTests(){ ...

Junit tests do not terminate when using Galileo eclipse on Ubuntu

Hi I'm using Galileo Eclipse on Ubuntu running inside a VirtualBox VM hosted on Windows XP. Eclipse is running under JDK 1.5 ( via the -vm command line switch ) The project that I am working with runs under JDK 1.3 ( set via the Build Path ) When I run a unit test from within eclipse ( by right clicking the source file and doing "Run...

Is there an alternative to mock objects in unit testing?

It's a Java (using JUnit) enterprise Web application with no mock objects pre-built, and it would require a vast amount of time not estimated to create them. Is there a testing paradigm that would give me "some" test coverage, but not total coverage? ...

JUnit output in Maven reports

Hi everybody! I am using Maven for my project and have following qustion: I want to see the logging output of my JUnit tests (log4j, System.out, whatever) in tests reports. Do you have any idea how to achieve this? Thanks ;-) ...