junit

Ant + JUnit = ClassNotFoundExceptions when running tests?

I'm trying to run some tests in Ant presently using JUnit, and all of my tests are failing with the following stacktrace: java.lang.ClassNotFoundException: com.mypackage.MyTestCase It doesn't make too much sense to me. I'm first compiling my test cases using <javac>, then directly running the <junit> task to run the tests. My buildfil...

Junit and EasyMock understanding clarifications

Still Now I am using JUnit, I came across EasyMock, I am understanding both are for the same purpose. Is my understanding correct? What are the advantages does EasyMock has over the Junit? Which one is easier to configure? Does EasyMock has any limitations? Please help me to learn ...

Maven2 junit timeout annotation doesn't work

We have a bunch of tests in a maven2 project and build with cruisecontrol. However the build regularly hangs, because the annotation of the test with a timeout @Test(timeout = 5000) is ignored. I tried and run maven locally, reproducing the fact that the timeout is ignored. Is there a way to activate the timeout for the tests again? ...

JUnitCore.runClasses doesn't print anything....

I have a test class that I'm trying to run from a main method with the folowing code : Result r = org.junit.runner.JUnitCore.runClasses(TestReader.class); when I examine the Result object I can see that 5 tests have been run but nothing is printed on the screen. Should I do something else to get an output ? ...

Using JUnit as an acceptance test framework

OK, so I work for a company who has openly adopted agile practices for development in recent years. Our unit tests and code quality are improving. One area we still are working on is to find what works best for us in the automated acceptance test arena. We want to take our well formed user stories and use these to drive the code in a ...

Does new JUnit 4.8.1 @Category render test suites almost obsolete?

Given question 'How to run all tests belonging to a certain Category?' and the answer would the following approach be better for test organization? define master test suite that contains all tests (e.g. using ClasspathSuite) design sufficient set of JUnit categories (sufficient means that every desirable collection of tests is identifi...

Java test framework for Selenium RC

I'm going to use Selenium RC to replay some tests for a website. I want to kickoff those tests from a Java test framework so that I get nice reports how many tests failed, etc. Which java test framework should I use? Is JUnit the preferred framework for this purpose? ...

Access POP3 account from JUnit tests

I'm looking for a way to access a POP3 account while running a JUnit test. Does anyone know how to do that? I probably need some kind of library for POP3 access I guess. ...

Trying to Unit Test A Class That Makes DB Queries Using Hibernate And Can't Get Session Created...

I am trying to implement JUnit tests for a class that performs DB queries using Hibernate. When I create the class under test, I get access to the session through the factory by doing the following: InitialContext context = new InitialContext(); sessionFactory = (SessionFactory) context.lookup(hibernateContext); This works fine when ...

Defining jUnit Test cases Correctly

I am new to Unit Testing and therefore wanted to do some practical exercise to get familiar with the jUnit framework. I created a program that implements a String multiplier public String multiply(String number1, String number2) In order to test the multiplier method, I created a test suite consisting of the following test cases (wi...

Basic jUnit Questions

I was testing a String multiplier class with a multiply() method that takes 2 numbers as inputs (as String) and returns the result number (as String) public String multiply(String num1, String num2); I have done the implementation and created a test class with the following test cases involving the input String parameter as ...

Hibernate Unit tests - Reset schema

Hi, I'm testing the CRUD operations of my DAOs in JUnit tests. When i execute the single test, Hibernate always resets the schema and populates the DB in a known state. But when i execute multiple tests in a row, Hibernate resets the schema once, and then the data is accumulated during the execution of the tests. This is an unexpected...

How do I create an ant builder file (build.xml) for an existing Java project?

Hi all, I am working on an Java assignment for a software design course in my university. It's not really complicated and it includes some classes, interfaces and jUnit test cases. We we're now told we should supply a build.xml file as an input for an ant builder. I have never heard of or used ant before. I also saw Eclipse supports it...

JUnit Test if XML Document is sorted on arbitrary column

Given an xml document like <root> <row> <a>2</a> <b>1</b> <c>8</c> </row> <row> <b>5</b> <a>2</a> <c>8</c> </row> <row> <a>2</a> <c>8</c> <b>6</b> </row> </root> Is there an easy way to assert that the XML document is sorted on element B in XMLUnit Edit: I have an odd problem with a pie...

@RunWith causes Maven to ignore my Test running with my own runner

I am moving from using only Intellij to manage my build system to Intellij/Maven. When I run my integration test "MapSimulationTest" with my own runner via @RunWith(KmlParameterizedRunner.class) Intellij correctly handles the situation, the directory specified by the system property "user.dir" is scanned for .kml files and each is teste...

JUnit Rule TemporaryFolder

I'm creating a TemporaryFolder using the @Rule annotation in JUnit 4.7. I've tried to create a new folder that is a child of the temp folder using tempFolder.newFolder("someFolder") in the @Before (setup) method of my test. It seems as though the temporary folder gets initialized after the setup method runs, meaning I can't use the tempo...

How to write a jUnit test for this class?

Hi, I would like to know what's the best approach to test the method "pushEvent()" in the following class with a jUnit test. My problem is, that the private method "callWebsite()" always requires a connection to the network. How can I avoid this requirement or refactor my class that I can test it without a connection to the network? c...

log4j vs. System.out.println - logger advantages?

Hi! I'm newly using log4j in a project. A fellow programmer told me that using System.out.println is considered bas style and that log4j is something like standard for logging matters nowadays. We do lots of JUnit testing - System.out stuff turns out to be harder to test. Therefore I began utilizing log4j for a Console controller clas...

Test problem using JUnitPerf

Hi, guys, I'm writing a JUnit test using JUnitPerf. Here, I want to generate some entries and use them to update a database. To test the capacity of the database, I want several test to run simultaneously or randomly, so I use, for example: Test loadTest = new LoadTest(testCase, n); But, still, I have to insure that in each test, a d...

How to handle ordering of @Rule's when they are dependant on eachother

I use embedded servers that run inside Junit test cases. Sometimes these servers require a working directory (for example the Apache Directory server). The new @Rule in Junit 4.7 can handle these cases. The TemporaryFolder-Rule can create a temporary directory. A custom ExternalResource-Rule can be created for server. But how do I handl...