I'm using the Spring transactional test classes to do unit testing of my DAO code. What I want to do is create my database once, before all the tests run. I have a @BeforeClass annotated method but that runs before Spring loads up the application context and configures the jdbcTemplate, thus I don't actually have a connection to the DB ...
Is there a way to cause hudson to report a build as failed, rather than unstable, if only a single unit test fails? thanks.
...
I have a Java class that simply extends a library class and calls a method of its parent with a default parameter. How do I write a Junit test for that? A MockObjectTestCase is good too. Here is an example of what I'm talking about:
public class ResourceBundleMessageSource {
public String getMessage(String key, Object[] objects, Loca...
I have a large application spread across multiple Spring bean definition xml files. In my test suite I manually load up the XML files I need using a FileSystemXmlApplicationContext to perform the tests I want to run. This reduces test set up time and allows me to use the same exact configuration files that are used in production.
Now I...
I'm getting this error when trying to run unit tests from Eclipse with an Android Project. The list of Instrumentation Test Runners is empty in the Android preferences.
[2009-06-17 23:57:51 - MyApp] ERROR:
Application does not specify a
android.test.InstrumentationTestRunner
instrumentation or does not declare
uses-library an...
assertEquals( new Long(42681241600) , new Long(42681241600) );
I am try to check two long numbers but when i try to compile this i get
integer number too large: 42681241600
error. Documentation shows there is a Long,Long assertEquals method but it is not called.
...
Reason: Our project is using Ant as commandline interface. After making a new assembly with maven's assembly plugin, I want to make initial tests to see if all has been properly assembled. Therefore I need to include the unit tests in the final assembly. After assembling, the initial tests would then be called sth like
> ant initTest
...
I want to run unit tests (Junit) on some model classes that typically will send emails confirming that things happened. Is there a mock email server that you can use with unit tests that will let you confirmation that your run tried to send an email without actually sending the emails out?
This seems like it would be a nice to have, ju...
I have an Eclipse project with many unit tests written in Groovy. I can run the tests in each individual class using Eclipse's GUnit run configuration. I open this configuration, select the "Run a single test" radio button, and select the class whose tests I want to run. This works fine, however I want to run all of the tests in the the ...
Has anyone been successful in using JiBX "bind on load" mechanism while running a JUnit test case? What were the steps taken? How did you managed to use IDE test running integration with this solution?
...
Is there a way I can get ant to run the unit tests just for the java classes it builds? For example, if MyClass.java is out of date, ant will build MyClass.class. After that I want it to also run MyClassTest and MyClassTestSuite if they exist. It doesn't have to be based on a naming convention. I'd be fine with using annotations or a...
I have a class that is responsible for network communication. I would like to have a unit test for it.
Here is where I'm stuck in order to write a test for it i have to implement a server to communicate with but that in turn will require its own test.
How do you write tests for a class such as this?
...
I marked a method with jUnit's @BeforeClass annotation, and got this exception saying it must be static. What's the rationale? This forces all my init to be on static fields, for no good reason as far as I see.
In .Net (NUnit), this is not the case.
Edit - the fact that a method annotated with @BeforeClass runs only once has nothing to...
Is there an equivalent to NUnit's ExpectedException or Assert.Throws<> in jUnit?
...
I'm trying to run a GWT unit test in a sample app. I ran
cmd /c /java/gwt-windows-1.6.4/webAppCreator.cmd -out gwttasks com.gwttasks.GwtTasks
Copied in junit-4.5.jar into a lib directory, and added that to the classpath.
Ran:
cmd /c /java/gwt-windows-1.6.4/junitCreator.cmd -junit lib/junit-4.5.jar -module com.gwttasks.GwtTasks -...
Our application has a service layer and a DAO layer, written as Spring beans.
While testing the Service Layer- I do not want to depend upon a real database so I am mocking that by creating a 'Mock' Impl for the DAO layer
So when I am testing the Service layer- I chain the Service layer beans to the Mock DAO beans
And in Production- wil...
I want to do some logging while executing my JUnit test. In JUnit 3.x it was always easy to obtain the name of the currently running test case, no matter how the test case was instantiated:
public void testFoo() throws Exception() {
String testName = this.getName();
// [...] do some stuff
}
In JUnit 4 things seem to be not so easy...
I can write an assertion message one of two ways. Stating success:
assertEquals( "objects should be identical", expected, actual );
Or stating the condition of being broken:
assertEquals( "objects aren't identical", expected, actual );
Is there a standard for this in JUnit specifically? If not, what are the arguments for each sid...
I am using Eclipse Galileo for Java EE, and I want to configure JUnit to show me the source code when I try to navigate to its methods. I've tried attaching source to the JUnit library, but the library definition is not editable. I cannot even find where to configure the JUnit library in the preferences.
When I open the Add Library wind...
Build Path > Add Library > JUnit unable to add JUnit3 or JUnit4 components.
I see such message in the .log
!MESSAGE No property tester contributes a property projectPersistentProperty org.eclipse.team.core.repository to type class org.eclipse.core.internal.resources.Project
Eclipse Galileo installed by root user on Linux.
It wor...