junit4

ejb testing issues with netbeans and openejb

I have created a netbeans 6.7 EnterpriseApplication project with ejb and war modules with a test stateless session ejb with a simple sayHello() method. I also added the openEjb library in order to unit test the ejb. Everything runs fine except that I keep getting the following error: Testsuite: com.myapp.test.NewEmptyJUnitTest Apach...

assertArrayEquals(Object[] o1, Object[] o2) cannot be found

My setup: Netbeans 6.7 Java6 JUnit 4.5 added as the Test libraries When I try to pass in two class arrays (cast as Object[]) I get the error "cannot find symbol" and my test case will not compile. I do not have an issue with the other assert statements, and as I said I am using the JUnit 4.5 libraries. Does anyone have a clu...

SpringJUnit4ClassRunner initialize beans for each test?

The following test illustrates that this test bean is initialized twice by Spring. I'm hoping someone can tell me why this is so, since it should only be once. Here's the test: import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.InitializingBean; import org.s...

why does junit4 not have Assert.assertArrayEquals() for double[]s?

There appear to be Assert.assertArrayEquals() methods in Junit4 for all primitives other than double, e.g. Assert.assertArrayEquals(int[] expected, int[] actual) and Assert.assertArrayEquals(char[] expected, char[] actual) but not Assert.assertArrayEquals(double[] expected, double[] actual, double eps) or Assert.assertArrayEqu...

Class teardown in junit 3?

We have a lot of integration tests written using JUnit 3, though we're now running them with 4.4. A few of these have a need for a tearDown method that runs after all the tests in the class are complete (to free some common resources). I see that this can be done in junit 4 with @AfterClass (org.junit). However, mixing this into exist...

Is it possible to programmatically generate JUnit test cases and suites?

I have to write a very large test suite for a complex set of business rules that are currently captured in several tabular forms (e.g., if parameters X Y Z are such and such, the value should be between V1 and V2). Each rule has a name and its own semantics. My end goal is to have a test suite, organized into sub test suites, with a tes...

Not able to execute tests with @Test annotation when my test extends TestCase(Junit) in Eclipse

Not able to execute tests with @Test annotation when my test extends TestCase(Junit) in Eclipse It works fine when I am not extending from TestCase(jUnit), but my existing code extends from TestCase hence I would like to keep that as it is. ...

Why is my junit test case treated like 3.x one when I extend from junit.framework.TestCase

I am trying to run my test case using junit 4.X runner, but it is treated like 3.x one when I extend from junit.framework.TestCase. I had to this as the out current test framework base test class extends from junit.framework.TestCase. ...

Limitations in JUnit4's annotations

Uri's answer got me thinking about what limitations JUnit 4 aquired by using annotations instead of a specific class hierarchy and interfaces the way JUnit 3 and earlier did. I'm wondering what limitations Annotations gave other people in using JUnit 4? One for me was the difficulty in creating a suite of dynamically generated classes. ...

Why shouly I use Hamcrest-Matcher and assertThat() instead of traditional assertXXX()-Methods

When I look at the examples in the Assert class JavaDoc assertThat("Help! Integers don't work", 0, is(1)); // fails: // failure message: // Help! Integers don't work // expected: is <1> // got value: <0> assertThat("Zero is one", 0, is(not(1))) // passes I dont see a big advantage over, let's say, assertEquals( 0, 1 ). It's nice may...

Cannot get FeatureSpec structure to show up in the output when combined with JUnitSuite

I am trying to use Scala's capabilty of running a class with either JUnit or ScalaTest. I took the example given for FeatureSpec and combined it with the example using JUnitSuite. I am having a problem generating the given/when/then output of Scalatest.FeatureSpec structure in the output (console) when combined with JUnitSuite. Any and ...

Ant PDE Tests Run with JUnit4

Hi, I am trying to automate pde tests, using pde-maven-plugin, maven calls ant task. I followed instructions here:http://www.eclipse.org/articles/article.php?file=Article-PDEJUnitAntAutomation/index.html to create the test.xml Tests failed, first because No Tests Found junit.framework.AssertionFailedError: junit.framework.AssertionF...

Maven Surefire reports show multiple class entries rather than a suite.

Hello, I've been asked to configure Maven's surefire report generator to include one entry for the test suite which in turn tests classes A,B and C but instead of seeing this: A B C MySuite I see this A B C A B C So there's two problems really: 1) How do I stop the tests running twice. 2) How do I get the report to show me one entry pe...

Ant + JUnit4 ClassDefNotFoundException - Classpath Issue?

[Edit] Solved, small mistake done by me being an ant beginner. In the test target, it needs to be <classpath refid="my.classpath"/> instead of <classpath id="my.classpath"/>. That obviously overwrote my defined classpath property. That makes it clear that ant is not able to find the library. Note to me: rtfm![/Edit] First things first: ...

JUnit tests run in eclipse return errors even though I have expected annotation

(This is a follow up question to this one.) I'm having a problem with JUnit4 tests in eclipse. I'm trying to use the @Test(expected=...) annotation to unit test exception throwing. The problem is that when I run the tests, they come back as errors instead of passing, even though I'm expecting the exceptions to be thrown. I'm using ecli...

Upgrading to JUnit4 and keeping legacy JUnit 3 tests and test suites by running them together

I was surprised not to find the answer so far. If I am missing something basic I will be more than happy to know that. There is a large legacy code base that was upgraded to Java 6 (from 1.4). Large number of JUnit 3 tests are present in the code and are organized into test suite that runs successfully with JUnit 4 default runner in Ecl...

JUnit 4 @BeforeClass & @AfterClass when using Suites

When using this approach below, by setting up the jUnit with Suites. We got the problem when all @BeforeClass in every Testclass will be executed before any tests starts to execute. (For each n TestClass file the @BeforeClass runs, then after they have execute, it started to execute the first MyTest.class files @Test) This will cause th...

Is there a JUnit 4+ test case execution priority toolkit?

Is there a JUnit 4+ test case execution priority toolkit? In the development teams I work we use JUnit 4+ for basic/unit testing and also for integration testing and system testing. 1) One trait of the integration and system test cases is that they generally take longer time to execute than unit tests, typically between 1 second - 60 ...

Maven 2 Not Running Junit 4 Tests

Hello, I'm having an issue getting surefire to run Junit4 tests. This same issue was reported in http://stackoverflow.com/questions/2021771?sort=newest#sort-top but the solution there was to removed the offending dependency whose transitive dependency caused the inclusion of junit3. In my case the dependency is necessary. I'm trying to f...

javadoc cannot find org.junit.Test

Hi All, When I run javadoc on my java source code, I get this error for th Junit test class: [javadoc] /mypath/TestStuff.class: warning: Cannot find annotation method 'expected()' in type 'org.junit.Test': class file for org.junit.Test not found The problem appears with junit version 4 with this type of annotation: @Test(expect...