junit

Ant build - Emma code instrumentation - JUnit tests need interfaces, Emma doesn't instrument them

I have an Ant build file where I compile the Java source code of the application and of the tests, instrument the application classes, run JUnit tests and generate JUnit and Emma code coverage reports. The JUnit task is given the path to the instrumented classes. The problem is that the interfaces are not instrumented (Emma FAQ) but I u...

How to use an uncaught exception handler for a multi-thread test in junit?

I have the following code that I expect to run successfully to completion but the code fails at the line "fail("this should not be reached");". Can someone please explain why the default uncaught exception handler is not called: public class UncaughtExceptionTest extends TestCase implements UncaughtExceptionHandler { private f...

GWT JUnit test in NetBeans

I have written application in GWT using NetBeans. Now I want to test my application with JUnit. I have never used JUnit before but I have basic concept of how it works. Now the question is how do I setup basic Unit test to test some of my GWT Widgets. I found THIS simple example but don't know how it can be ran in NetBeans. ...

Maven2 + JMeter + JUnit with dependencies

I'd like to run my JUnit tests in JMeter. Using maven-jar-plugin I can create a jar with my tests in order to put it inside the JMeter's classpath ($JMETER_HOME/lib/junit). The problem is that my tests have a lot of dependencies that Maven2 doesn't put into the jar, including the main classes of the project, classes from other projects a...

Selenium not opening virtual browser window on Linux

Hello all, I am using Selenium to conduct user interface tests with JUnit, in a Maven project. The project is located on a Linux box running IEs4Linux and Wine to allow us to run the tests in IE. Right now I'm using Xming along with Putty to view the virtual browser windows, and I am able to open an IE window with the command "ie6", an...

PDE headless build: howto run junit tests via ant and cruisecontrol

Hi all, I am working on the automated pde headless build of my rcp application. This works fine after I have solved this issue: target-platform-for-pde-headless-build-does-not-work Now I want to do 2 more things: Integration of that process into cruisecontrol and run my junit-tests which are located in a separate plugin after a successf...

Spring/Hibernate testcase error

I am using spring and hibernate and currently making test case for database test and i am getting this error Error: Before Test CaSe SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1e91a4d] to prepare test instance [com.Test.TestClass@bdc9b3...

maven-cobertura-plugion does not show the sources.

When I generate a Cobertura report by running "mvn cobertura:cobertura" (or "mvn site") then a report is generated which shows the test coverage for my classes but when I click on a class then the message "Unable to locate de/ailis/foo/Bar.java. Have you specified the source directory?" is displayed. How can I fix this? I configured the ...

Is there any reason in Junit not to create your objects at the declaration?

Is there any reason to put object creation inside of setUp() rather than at an instance variable declaration? I've seen it done this way in books, but the effect is the same and I'm not sure if it was done for a best practice reason, because an earlier version of Junit did not instantiate the object for each test (see here), or if it's ...

Which Continuous Integration Plugin for Eclipse

I do a lot of TDD and am thinking of installing a Continuous Integration Plugin for Eclipse. The two most popular seem to be JUnit Max and Infinitest. As both are "payed for", I'd like some opinions on the pros/cons/otherwise of each. Maybe there is a "free" alternative that I've missed? ...

JUNIT Tests for OSB services

hi, Can we have Junit Test cases for testing Proxy, Business Services in Oracle Service Bus? If yes can someone give me some pointers to the same. ...

JUnit 4.8.1 / Maven trivial test not working

Hi Although I tried out all suggestions I found, I still can't get the most trivial JUnit test running. The error message basically repeats saying "junit.framework.AssertionFailedError: No tests found in project002.trivial.TestClassTest". You may inspect a snapshot of my IDE or download the zipped project. Here is my pom.xml: <projec...

Spring Transactional Unit Tests - Hibernate Queries Not Rolling Back

I am using Spring 3, and Hibernate 3.5, I am not getting my transactions to rollback in the test environment, which has me worried they would not be rolled back in production either. Test Class: @ContextConfiguration(loader = MyConfigurationLoader.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollb...

testing the class that returns the service using powermock?

hi, I want to test certain underlying services using powermock. but it is complicated. i would like to get your suggestion public interface service{ public void some_method(){ } } public serviceclient implements service { ... } public myserviceclient { public service getService(){ return service; } } I have written a servi...

Using Eclipse to create a new JUnit test case

I have a question about using Eclipse to write an additional JUnit test case for an existing Java application. There's a folder called "pass" which contains all of the pass tests. I create a new pass test by right clicking on the folder and going to New -> File. However, when I create the JUnit test case, the new test doesn't show up a...

Assert List in Junit

Hi, How to assert list in Junit test case ? I mean not only the size of the list but also the contents of the list. Thanks, Kamal ...

Java/ JUnit - AssertTrue vs AssertFalse

Hello all, I'm pretty new to Java and am following the Eclipse Total Beginner's Tutorials. They are all very helpful, but in Lesson 12, he uses assertTrue for one test case and assertFalse for another. Here's the code: // Check the book out to p1 (Thomas) // Check to see that the book was successfully checked out to p1 (Thomas) assertT...

Junit GWT error - Cannot find function attachEvent in object [object Window]

I try to create junit test for my GWT application. The application uses MathJax javascript library. I encounter an error that seems to be connected with javascript code. The listing of the full error message is here. I think that the core (main cause) of the error could be the following: TypeError: Cannot find function attachEven...

Where to put reusable testing methods used in several grails test classes

I often need to set up the same test structures for different test cases. Therefore I created a TestService class that has several public methods for the test classes. I guess that this is not the best place to put them as TestService will also be deployed although not needed on production. Where would you put those commonly test metho...

Get Class name from within a method

I would like to reference a Class's name within a method. In the following example, I would like TestSuite to be printed out. I can put CarsTestSuite.class.getName(), but I'd like to use the method to get the class name so that I never have to edit it. The solution will find the method's class instead of myself filling it in. public ...