junit

Problem in running Junit tests in eclipse 3.4.1 on Mac OS

Problem in running Junit tests in eclipse 3.4.1 on Mac OS I am getting this error: 'Lanuching AllTests' has encountered a problem. Cannot connect to VM. !ENTRY org.eclipse.core.net 1 0 2009-01-29 10:07:44.047 !MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.25 4/16|*.169.254/16 by an external source. This...

Comparing XMLs using XMLUnit RecursiveElementNameAndTextQualifier

Hi, I am trying to compare 2 XML files using XMLUnit 1.2. I am using the RecursiveElementNameAndTextQualifier() qualifier. When changing the order of some entities order in my XML, it causes XMLUnit to pass on some cases and fail on other cases. My XML file looks like this, and I'm comparing it to a similar copy with a simple locat...

Best Practice: Initialize JUnit class fields in setUp() or at declaration?

Should I initialize class fields at declaration like this? public class SomeTest extends TestCase { private final List list = new ArrayList(); public void testPopulateList() { // Add stuff to the list // Assert the list contains what I expect } } Or in setUp() like this? public class SomeTest extends ...

Ordering unit tests in Eclipse's JUnit view

The JUnit view in Eclipse seems to order the tests randomly. How can I order them by class name? ...

What do you think of JUnit style Unit Testing, do you favor Behaviour Driven Testing?

I don't know if you read the recent post by Joel, but basically he says that you don't need unit testing for every unit or piece of code in your code base. "And that strikes me as being just a little bit too doctrinaire about something that you may not need. Like, the whole idea of agile programming is not to do things before you need t...

Why do you use .proxy() in JMock?

Hi, I'm trying to learn how to use JMock and I'm a bit confused about what you use the .proxy() method for. I know its invoked on your Mock class but I don't understand what its puprose is. I haven't had any luck finding a good description about how it works on google. Any help is much appreciated. ...

The XML code runs properly, but junit fails with NoClassDefFound

I am upgrading my environment from eclipse 3.3.1 and java 1.4 to eclipse 3.4.1 and java 1.5. My unit tests are in jUnit 3. eclipse java version 1.5.0__17 stand alone env version 1.5.0__12, or 1.5.0-17, both work. I have a method on a class that writes an XML file to disk. It calls TransformerFactory tf = [javax.xml.transform.]Transfor...

using junit 4 in grails

I'd like to use some JUnit 4 functionality in my grails testing, but currently grails tests run under JUnit 3. JUnit 4 can be used from groovy but replacing the JUnit jar within grails with a JUnit 4 one doesn't seem to enable the functionality I'm looking for. Anyone know how I can get grails to run my tests with junit 4? ...

Generating JUnit Testcases

Our application depends on numerous resources that are provided by another system. To ensure the existence of those resources, we currently have a JUnit test case (probably more an integration test), that takes a list of all the resources as a textfile, fetches each and tracks success/failure. This is a very long running testCase that ...

removing junit testing to build in ant

Not so much a programming question but I figured I'd ask anyway. How do I make it so ant doesn't require that all the junit tests pass before building? In netbeans I can build the project without it testing first. However, when I run ant, it makes sure all my junit tests pass first. I am running ant from the command line in my netbea...

Besides "all of them" as an answer, what type of applications (be specific) have had true success with unit testing?

What type of applications did you use this TDD, unit testing approaching (web app, compiler, rails, etc?). What language was your application written in? Did you use a preexisting unit testing frameworking like junit or nunit or did you you rollo your own. Did you use automatically code generate your test cases or was most of the work t...

JUnit before and test

What is the use of a Junit before and Test package in java? how can i use it with netbeans? ...

What are good practices for unit testing J2EE/Web applications

What are the best ways to test servlet oriented web applications. With possibly jdbc backed backends. Front-end = Struts2 and some servlets Back-end = hibernate, some basic jdbc ...

To find the number of test methods in a JUnit TestCase

Is there a way to know the number of test methods in a test case? What I want to do is have a test case which tests several scenarios and for all these i would be doing the data setUp() only once. Similarly I would like to do the cleanup (tearDown()) once at the end of all the test methods. The current approach i am using is to mainta...

Force JUnit to run one test case at a time

I have a problematic situation with some quite advanced unit tests (using PowerMock for mocking and JUnit 4.5). Without going into too much detail, the first test case of a test class will always succeed, but any following test cases in the same test class fails. However, if I select to only run test case 5 out of 10, for example, it wil...

What is the recommended way to log data that caused errors in JUnit?

I'm relatively new to JUnit, and I was writing a few of my first tests today. For some particular method, I wanted to pass random values (all of which are within the correct range). If the method fails for any reason, I want to know which value caused it to fail. So what's the recommended way of doing this? (Or is it bad to use random v...

Powermock Slows Down Test Startup on Eclipse/Fedora 10 when on NTFS partition

I've just started having a proper play with Powermock and noticed that it slows down test startup immensely. A quick look at top while it was running shows that mount.nfts-3g was taking up most of the CPU. I moved Eclipse and my source directory to ext3 partitions to see if that was a problem and the tests now startup quicker but there...

Weird JUnit logging behavior

I'm noticing some weird behavior using standard logging during JUnit tests. Does JUnit redirect standard output to a different stream? How can I get access to that? Here's a simple JUnit test that demonstrates the behavior I'm describing. @Test public void logMessage() { // set up new logger with output directed to standard out ...

Can I use jtracert to sequence diagram a unit test running in eclipse?

How would I go about using jtracert to sequence diagram a junit test being run within eclipse? ...

How do I verify a method call and ignore the return value in EasyMock?

I'm getting frustrated trying to do a simple thing - I want to invoke a method on a mock object and NOT check its return value. I just want to check that it was invoked with the correct parameters. Example: MyInterface mockObject = createMock(MyInterface.class); SomeObject param = new SomeObject(); /* the write object is not void and ...