junit

Bringing unit testing to an existing project

I'm working on an existing JEE project with various maven modules that are developed in Eclipse, bundled together and deployed on JBoss using Java 1.6. I have the opportunity to prepare any framework and document how unit testing should be brought to the project. Can you offer any advice on... JUnit is where I expect to start, is this...

NetBeans 6.9 and JUnit 4.8.2 package visibility problem

Hello, I recently upgraded from NetBeans 6.7.1 to NetBeans 6.9 and my old JUnit tests are showing "cannot find symbol" errors in the NetBeans editor around the import statements. Everything builds correctly on these unit tests and I can still run/debug the unit tests without any issues. However, auto-complete within the editor doesn...

What is the right java unit test library for http?

Hello all, I am developing a servlet application, I was using JWebUnit, to check all the basic responses, but now I have to start using other HTTP methods different to GET(POST,PUT and DELETE). So, I found HttpUnit, it looks that have support for what I need, POST and PUT methods are available there and I guess I can walk around the DE...

How can I run all JUnit tests in one package @ NetBeans ?

Hello! I have like trillion test packages with bazillion tests and I want to run just some of packages. Now I must run whole project (some tests takes long to complete) or I need to run every single file manually. How is possible to run just some packages in NetBeans ? I can't find this option ... ...

JUnit 4.x : why is @Before never executed ?

When I create an and run unit-test, (in Eclipse (Galileo) with JUnit 4.5 or 4.82), the @Before is never executed (?). Below is some sample-code. I would expect the output to be : initialize testGetFour But it is just : testGetFour @BeforeClass and @AfterClass are never executed either. Can someone tell me how come ? p...

Set System Property With Spring Configuration File

Configuration: Spring 2.5, Junit 4, Log4j The log4j file location is specified from a system property ${log.location} At runtime, system property set with -D java option. All is well. Problem / What I Need: At unit test time, system property not set, and file location not resolved. App uses Spring, would like to simply configure Sp...

Is Unit Testing worth the effort, in a large and old (5yr) codebase?

I've just joined a team which has been working in a main-always mode for the last 5 yrs (java, maven based project). Consequently plans to leverage unit testing have always been in the pipeline, never materialising (so far). A Great dev team has ensured that code quality is generally good, and there aren't structural code issues, but the...

Junit @Before annotation is giving a Nullpointer exception

I am using junit 4.8.1. The following is the code. I am getting "Nullponiter" exception. I suspect that the "SetUp" code under @Before is not been excecuted before other methods. Request the learned friends to help me in resolving the issue. (This is an example for TDD book by Koskela) import org.junit.*; import java.util.*; import sta...

Junit and Selenium and tearDown

Hi all; Such a junit : @Test public void testA {...} @Test pulic void testB {...} @After public void closeBrowsers() Exception { selenium.stop(); } Here is the question : closeBrowsers() method called after every test method; in that case it is called twice and i got "Wrong test finished." from JUnit. I need a junit method/annota...

How to unit test this ?

I've been playing around with .NET SpeechSynthesizer lately. and I've got a method that takes in a string and creates a .wav file out of that string. but how do I unit test this method ? seems to me like this situation is one in which unit testing cannot help you. am I right ? ...

How do I test local inner class methods in java?

In many application I often have algorithms which make use of dedicated sub-algorithms (or simply well defined pieces of code). Till now, when I wrote the main algorithm, i created a private method for each sub-algorithm like in the example below (OldStyle): public class OldStyle { public int mainAlg() { int x = subAlg01(...

How does JUnit find the eclipse plug-in being tested?

I am writing a plug-in (ClassRefactoringPlugin) that examines source code in Eclipse 3.5.2. The plug-in contains a CallData class that examines a Java source file and figures out which Java elements are called from a method using JDT operations. I wrote a JUnit 4 test for this class that also resides in the ClassRefactoringPlugin proje...

Dynamic Junit Test

Hello As part of my study final project I have to make a J2EE application that allows users to run JUnit tests(without any experience what they have to do is to click and see the result), obviously it must be some way to modify tests and create new ones (upload new test files ...) could you point me to the right technology which allows...

JUnit Parameterized Testing

Is there any annotation in Junit to exclude a non param test in parameterized test class? ...

Runtime Exception in Android JUnit testing

I have a simple HelloWorld Activity that I try to test with an Android JUnit test. The application itself runs like it should but the test fails with an "java.lang.RuntimeException: Unable to resolve activity for: Intent { action=android.intent.action.MAIN flags=0x10000000 comp={no.helloworld.HelloWorld/no.helloworld.HelloWorld} } at n...

Validating number of failing Junits in ANT

I would like to run a JUnit regression Test Suite from within an ANT build script. The test suite has a known number of failures which we are working towards fixing. I want the build to fail if the number of failing tests increases (or changes at all if that's easier to code) - this value can be hard coded in the ANT script. I'm looking...

use cactus and junit 4 at the same

Is it possible to use cactus and Junit 4 at the same time? Because I know that current cactus release is based on Junit 3.8. Cactus looks like hasn't been maintained for a long time,doesn't even support annotation, is there any better framework to replace cactus? ...

Do any tools use the hamcrest Factory annotation?

I sat down to write a matcher today and decided to take a quick look at the jmock documentation to refresh my memory on the process, and noticed a reference to the org.hamcrest.Factory annotation. The documentation for the annotation states. Marks a Hamcrest static factory method so tools recognise them. A factory method is an equiv...

How do I make Eclipse recognize JUnit tests when creating a suite?

When I use Eclipse to create a JUnit test suite, it does not detect any existing tests, and warns "No test classes selected." I started from the test class package (test/com/.../package), and the package is selected. There are several JUnit tests there, also created through the same version of Eclipse, but there is no way to select the...

Running tests on multiple browsers with selenium grid and junit

I am trying to set up automated selenium testing but don't know how to run tests in multiple browsers. Based on reading stuff online I have selenium grid up and running with multiple browsers and it successfully executes my tests. I am trying to figure out how to setup my junit tests so that it runs all the browsers one after another or...