junit

Getting useful emails from Hudson instead of tail of ant log

A team member of mine recently setup some Hudson continuous-integration builds for a number of our development code bases. It uses the built in ant integration configured in simple way. While, it is very helpful and I recommend it strongly, I was wondering how to get more more concise/informative/useful emails instead of just the tail ...

Need an example for using Junit in Intellij Idea

Maybe it's just me, but I cannot understand the documentation regarding Junit test integration in Intellij Idea. What I am looking for is a simple tutorial example, such as: Here is a method calculating 2+2, and here is a test class testing it to be 4. This is the checkbox you set to make it go. If there is already such a thing on the we...

Running a junit4 test with junitperf

Hello It' possible to use Junitperf with junit4? I've a simplet Junit4 test class with several tests and i want to do a TimedTest on single test of that class. How can i do that? To be more clear my Junit4 class is something like: public class TestCitta { @Test public void test1 {} @Test public void test2 {} } w...

JUnit gives no information regarding "errors"

I'm using Junit 4.4 and Ant 1.7. If a test case fails with an error (for example because a method threw an unexpected exception) I don't get any details about what the error was. My build.xml looks like this: <target name="test" depends="compile"> <junit printsummary="withOutAndErr" filtertrace="no" fork="yes" haltonfailure="yes" show...

How do I activate JButton ActionListener inside code (unit testing purposes)?

Hi, I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit. Basically I have this: public class MyDialog extends JDialog { public static int APPLY_OPTION= 1; protected int buttonpressed; protected JButton okButton; public MyDialog(Frame f) { super(f); okButt...

Handle Swing events in JUnit test

I have Swing java application with network communications to several "Players" that are represented as player objects, each with their own communication thread. The app has a "Team" object managing all player objects. Several UI components listen to events passed from the players through the Team object. In my design, the team object f...

Is running tests with JUnit 3.x vs JUnit 4.x still a best practice?

I haven't looked at this in a while, but if I recall correctly both ant and maven still rely on JUnit 3 for unit tests (as of maven 2.09 the default POM file still has JUnit 3.81). Does it still make sense to stick to JUnit 3 instead of using the latest and greatest? Any good reason I might be missing? ...

Runinng SQL script from JUnit

In the setup method to a JUnit test case I'm working on I need it to run a sql script on my database before each test case, and then a rollback afterwards. I have tried using a tokenizer, which added each SQL command to a batch and then executing them. But I can't get working. So my question is if there is some standard method in JUnit ...

Should @Entity Pojos be tested?

I don't know if I should test my @Entity-annotated Pojos. After all, there are mainly just generated getters/setters. Should I test them? When it comes to testing DAOs I'm using all those entities - so they are already propely tested, I guess? Thanks for your thoughts. Matt ...

AOP problem running Spring unit tests

I have a Spring web application which is configured to use JDK proxying for AOP. The AOP annotations (such as @Transactional) are declared on the interfaces, rather than the implementation classes. The application itself works fine, but when I run the unit tests, it seems to be attempting to use CGLIB for the AOP functionality (instead ...

JUnit 4: Set up things in a test suite before tests are run (like a test's @BeforeClass method, just for a test suite)

I want to do some functional testing on a (restful) webservice. The testsuite contains a bunch of test cases, each of which performs a couple of HTTP requests on the webservice. Naturally, the webservice has to run or the tests will fail. :-) Starting the webservice takes a couple of minutes (it does some heavy data lifting), so I want...

Confirming from a JUnit test that a FileReader was closed properly

I'm writing some Java code that uses a FileReader to load data from a few input files. I'm using TDD pretty heavily, and I'd like to add some tests that ensure that I'm cleaning up properly by calling close() on the reader when I'm done with it. Unfortunately, I can't come up with a good way to test for this. Anyone have any insights? E...

JUnit test with dynamic number of tests

In our project I have several JUnit tests that e.g. take every file from a directory and run a test on it. If I implement a testEveryFileInDirectory method in the TestCase this shows up as only one test that may fail or succeed. But I am interested in the results on each individual file. How can I write a TestCase / TestSuite such that e...

ParameterizedTest with a name in Eclipse Testrunner

When you run a JUnit 4 ParameterizedTest with the eclipse testrunner, the graphical representation is rather dumb: for each test you have a node called [0], [1], etc. Is it possible give the tests [0], [1] etc. explicit names? Implementing a toString method for the tests does not seem to help. (This is a follow-up question to JUnit test...

Can't run Groovy unit tests in NetBeans 6.5

There is no new Groovy Unit Test built into NetBeans. And if I create one manually, I can't get it to run in NetBeans. Is it not implemented, or is there something wrong with my installation? ...

Unit testing a Hibernate driven application?

This may be a naive question, but I am new to both the junit and hibernate frameworks and I was wondering what the best way to go about unit testing an application that is largely calls to hibernate, or if it is even necessary to do so? What is the best practice here? EDIT: Spring seems to be the big suggestion here. Unfortunately thi...

Should I unit test methods which are inherited from super class?

I'm currently writing an implementation of a JDBC driver (yes, you read that correctly) in a TDD manner and while I have only finished class stubs at this point and only some minor functionality, it just occured to me that since Statement is a superclass for PreparedStatement which is a superclass for CallableStatement, what should I do ...

Is it possible to run JUnit tests from multiple packages in Eclipse?

Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites. For example if I have the hierarchy: code.branchone code.branchone.aaa code.branchone.bbb code.branchtwo code.branchtwo.aaa code.branchtwo.bbb Is it possible to: Run all tests in code.branchone and in descendent packages R...

Setting up Mobile JUnit tests to run under JUnit

I'm using Mobile JUnit, released by Sony Ericsson for unit testing for my J2ME project. I read in the documentation that one can run the tests under regular junit with the help of a few wrapper classes. The documentation, in fact, recommends that you do this if you want to generate reports for CI builds, etc. which is exactly what I want...

How to run test cases on a list of slightly different jars ?

I have a list of jar files, all containing slightly different versions of the same system. I want to execute a set of test cases on each jar file while being able to obtain the results for each jar (via RunListener or something like that). I am a bit confused with the class loading problems that are implied. How can I nicely do this ?...