junit

writing junit test to cover cross version serialization

does any of you have any info/idea on how can I test my application for cross version compatibility. I am testing these object's serialization in current "HEAD" version. but I need to wait for my integration testing to see if I broke anything cross version. I am guessing I will need to store the objects serialized from last released ver...

junit4 test runner

hello how could we uses junit related methods? could we launch setup once from each java test? if in my test I launch the apply by calling setup once, is it correct ? ...

jUnit same exception in different cases

Hi, I'm writing a jUnit test for a constructor that parses a String and then check numerous things. When there's wrong data, for every thing, some IllegalArgumentException with different message is thrown. So I would like to write tests for it, but how can i recognize what error was thrown? This is how can I do it: @Test(expected=Illega...

Need help with developing a class for my JUnit test

I have this JUnit test that I need help developing a Interface and Class for, here is the test: Box b1 = new DefaultBox( "abc" ); Box b2 = new DefaultBox( "def" ); Box b3 = new DefaultBox( "" ); assertEquals("abc", b1.contents()); assertEquals("[abc]", b1.toString()); assertTrue(b1.equals(b1)); assertFalse(b1.equals(b2)); assertFa...

Verify XHTML is valid in a JUnit test?

I have a Spring controller that returns XHTML, what's the easiest way to setup a JUnit test that verifies that the XHTML is valid? I'd also like to verify certain elements are present. ...

Issue selenium code maintenance

I want to group the common methods in one file and use it. For example, login to a page using selenium may be used in multiple times. Define that in class A and call it in class B. However, it throws null pointer exception. class A has public void test_Login() throws Exception { try{ selenium.setTimeout("60000"); ...

Junit Parameterized tests together with Powermock - how!?

Hi! I've been trying to figure out how to run parameterized tests in Junit4 together with PowerMock. The problem is that to use PowerMock you need to decorate your test class with @RunWith(PowerMockRunner.class) and to use parameterized tests you have to decorate with @RunWith(Parameterized.class) From what I can see they ...

how to test this portion of code

Hello I'm writting junit test how can I test this method .. this is only part of this method : public MyClass{ public void myMethod(){ List<myObject> list = readData(); } } How will I make the test for this? ReadData is a private method inside MyClass? ...

How do you set a custom session when unit testing with wicket?

I'm trying to run some unit tests on a wicket page that only allows access after you've logged in. In my JUnit test I cannot start the page or render it without setting the session. How do you set the session? I'm having problems finding any documentation on how to do this. WicketTester tester = new WicketTester(new MyApp()); ((M...

Injecting Mockito mocks into a Spring bean

I would like to inject a Mockito mock object into a Spring (3+) bean for the purposes of unit testing with JUnit. My bean dependencies are currently injected by using the @Autowired annotation on private member fields. I have considered using ReflectionTestUtils.setField but the bean instance that I wish to inject is actually a proxy an...

Automated testing in Android development

I have an ordinary project with JUnit tests that are connected to the classes in my Android Project. I want my server to run some JUnit tests in my testproject everytime I commit my code from my Android Project. Is there a best practise to do this? So far I only managed to run the tests when they are a part of a while the JUnit tests a...

Maven - Selenium - Possible to run only one test

Hi We are using JUnit - Selenium for our web tests. We use Maven to start them and build a surefire report. The test suite is pretty large and takes a while to run and sometimes single tests fail because the browser won't start. I want to be able run a SINGLE test using maven so I retest the tests that fail and update the report. I ca...

Unit testing several implementation of the same trait/interface

I program mostly in scala and java, using scalatest in scala and junit for unit testing. I would like to apply the very same tests to several implementations of the same interface/trait. The idea is to verify that the interface contract is enforced and to check Liskov substitution principle. For instance, when testing implementations of...

How was the first release of JDK Unit Tested?

Can someone please explain the following How was the first JDK release unit Tested? Since Junit came after Java how did they do it? Are the current releases using Junit to test the JDK API? Regards ...

How to count the number of open editor instances in an Eclipse RCP Application?

Hello! :-) I'm beginning to use the swtbot to test my reccent eclipse rcp projekt. A specific editor is opened multiple times in my application and want to count how often the editor is opened. How can i do that using swtbot? Thanks! :-) ...

How to get full stack traces logged when a JUnit test running in ant fails?

When a JUnit test throws a runtime exception while running in Eclipse, you can see the entire stack trace. Our build server uses ant and runs JUnit, but the printout on failure only provides the exception's message, not the entire "printStackTrace". Is there a convenient way to get this functionality? ...

Java Junit testing problem

Hi All, I am using Junit 4. My whole program is working fine. I am trying to write a test case. But there is one error... here is very basic sample test public class di extends TestCase{ private static Records testRec; public void testAbc() { Assert.assertTrue( "There should be some thing.", di....

Assigning static final int in a JUnit (4.8.1) test suite

I have a JUnit test class in which I have several static final ints that can be redefined at the top of the tester code to allow some variation in the test values. I have logic in my @BeforeClass method to ensure that the developer has entered values that won't break my tests. I would like to improve variation further by allowing these ...

Running JUnit test classes from another JUnit test class

I have two classes that I am testing (let's call them ClassA and ClassB). Each has its own JUnit test class (testClassA and testClassB respectively). ClassA relies on ClassB for its normal functioning, so I want to make sure ClassB passes its tests before running testClassA (otherwise the results from testClassA would be meaningless). ...

getPackage() returning null when my JUnit test is run from Ant

I'm having problems running a JUnit test. It runs fine in Eclipse, but now I'm trying to run it from the command-line using Ant. The problem is that the following code is returning null: getClass().getPackage(). I'm running my JUnit test like so: <junit fork="no" printsummary="yes" haltonfailure="no"> <classpath refid="j...