junit

Unit testing installation of services

Our installer program is going to be installing a number of system services, under both Windows and UNIX, using JavaServiceWrapper. There will be a class responsible for creating JavaServiceWrapper config files, installing the services, etc. Can I have some suggestions on how to unit-test this class? ...

Eclipse + Android + JUnit test references android.os class = NoClassDefFoundError

I have a custom timer that extends android.os.CountDownTimer. I have a test in the test project (standard Android/Eclipse project config) that tests the custom Timer. When I run this test, I get: java.lang.NoClassDefFoundError: android/os/CountDownTimer   at java.lang.ClassLoader.defineClass1(Native Method)   at java.lang.ClassLo...

Junit Ant Task, output stack trace

I have a number of tests failing in the following JUnit Task. <target name="test-main" depends="build.modules" description="Main Integration/Unit tests"> <junit fork="yes" description="Main Integration/Unit Tests" showoutput="true" printsummary="true" outputtoformatte...

How to configure IntelliJ for running test with JUnit 4?

Should be simple but I couldn't figure it out. When running my unit test inside IntelliJ, I could not find a way to tell IntelliJ-9.0 that it should use JUnit4 instead of JUnit3. When a test fails, IntelliJ console displays: MyTests.testConstraints(MyTests.groovy:20) at ... com.intellij.junit3.JUnit3IdeaTestRunner.doRun(...

Yet another Ant + JUnit classpath problem

Hi, I'm developing an Eclipse SWT application using Eclipse. There are also some JUnit 4 tests, which test some DAO's. But when I try to run the tests via an ant build, all of the tests fail, because the test classes aren't found. Google brought up about a million of people who all have the same problem, but none of their solutions see...

Can I run perl unit tests under ant jUnit task? How can I handle perl unit tests errors within ant build script?

I'd like to deploy my set of perl scripts by ant. I'm going to run perl test scripts in the ant build.xml and I want to handle perl errors. That's why I wonder, how does ant task work? Does junit parse output of tests? In this case I can transform TAP output within TAP::Formatter::JUnit CPAN module. http://search.cpan.org/dist/TA...

JUnit: checking if a void method gets called

I have a very simple filewatcher class which checks every 2 seconds if a file has changed and if so, the onChange method (void) is called. Is there an easy way to check ik the onChange method is getting called in a unit test? code: public class PropertyFileWatcher extends TimerTask { private long timeStamp; private File file; public ...

How to rewrite data-driven test suites of JUnit 3 in Junit 4?

I am using data-driven test suites running JUnit 3 based on Rainsberger's JUnit Recipes. The purpose of these tests is to check whether a certain function is properly implemented related to a set of input-output pairs. Here is the definition of the test suite: public static Test suite() throws Exception { TestSuite suite = new Test...

Does the JUnit framework have tests ?

JUnit, being a testing framework, does it have tests itself ? ...

java.lang.exception no runnable methods junit

Hi All, I have a suite, inside which i have added the test class. I am using surefire to run my Junits. MY test class ends with test and the methods has @test annotations to it. Please help me to resolve the problem. Thanks and Regards, Saurav ...

Making ehcache read-write for test code and read-only for production code

I would like to annotate many of my Hibernate entities that contain reference data and/or configuration data with @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) However, my JUnit tests are setting up and tearing down some of this reference/configuration data using the Hibernate entities. Is there a recommended way of having entiti...

When should we use Mockery vs JUnit4Mockery?

If writing a Java unit test with mocking using JMock, should we use Mockery context = new Mockery() or Mockery context = new JUnit4Mockery() What is the difference between the two, and when should we use which? ...

Junit before class ( non static )

Are there any best practices to get Junit execute a function once in a test file , and it should also not be static. like @BeforeClass on non static function? Here is an ugly solution : @Before void init(){ if (init.get() == false){ init.set(true); // do once block } } well this is something i dont want to do...

How to unit test synchronized code

Hi, I am new to Java and junit. I have the following peice of code that I want to test. Would appreciate if you could send your ideas about what's the best way to go about testing it. Basically, the following code is about electing a leader form a Cluster. The leader holds a lock on the shared cache and services of the leader get resum...

Tests for JUnit. How ?

How is the JUnit Framework tested ? How are the tests for their framework code created, considering that JUnit as a testing framework itself. What technology are they using ? Their own testing framework ? A smaller more basic version of it ? Another framework ? Can any knower please provide some details ? ...

JUnit terminates child threads

Hi to all, When i test the execution of a method that creates a child thread, the JUnit test ends before the child thread and kills it. How do i force JUnit to wait for the child thread to complete its execution? Thanks ...

VerifyError When Running jUnit Test on Android 1.6

Here's what I'm trying to run on Android 1.6: package com.healthlogger.test; public class AllTests extends TestSuite { public static Test suite() { return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build(); } } and: package com.healthlogger.test; public class RecordTest extends AndroidTes...

Can't run jUnit with Eclipse

I use new Eclipse. Create demo test with jUnit (I added default jUnit library built-in Eclipse). Then I write this code: import junit.framework.*; import org.junit.Test; public class SimpleTest extends TestCase { public SimpleTest(String name) { super(name); } public final void main(String method){ } @Test ...

Hudson results one step behind

I'm using the filesytem plugin for Hudson, and when a build happens it looks for new/modified files, copies them to the Workspace, runs tests using Rake, and then publishes those junit xml result files. However, the updated junit xml result files don't get pushed to the workspace until the next build. This means that when the publishin...

Automation of testing using JUnit

Hi, i am trying to automate manual testing of modules in my project. We are dealing with IBM Websphere Message queue software. We have a trigger component written in core java which when executed polls for availability of message in the configured queue. Its an indefinite while loop that keeps the trigger component running. I have writte...