junit

Why would extending JerseyTest vs extending TestCase cause no tests to be found.

I am attempting to get the Jersey test framework working. We are building using maven 1.x. I've created the following testcase... public class SomeResourceTest extends JerseyTest { public SomeResourceTest () throws Exception { super(new WebAppDescriptor.Builder(PACKAGE_NAME) .contextPath(PATH).bu...

How to let maven run a single test class with non-default profile activated?

I'm trying to let maven run a single test class but I need to use an additional profile (which in fact is already created). Normally when I run: mvn clean install -PmyProfile "myProfile" is being activated. So I tried: mvn -Dtest=myTest -PmyProfile test Which resulted in "[WARNING] Profile with id: 'myProfile' has not been activ...

Selenium assertText for all text in a table?

I need to assert that each row in table contains a certain text string, either through selenium IDE or a Java test case. What's the best way to do this? Here's my current test: Command assertText Target //table[@id='myTable']//tbody//tr[not(@style)]/td[1] Value myValue I need to test the first column of every row, but this...

SoapUI and JUnit integration

According to documentation we can remotely execute soapui tests from JUnit. But how to connect all jars properly and get access to SoapUITestCaseRunner class ? ...

Writing test case for Junit testing

Hi, As a developer, I'm a newbie to Unit testing and have a requirement to write a test case to unit test the following code. Could somebody help me here and also give me some pointers on how to write unit tests in eclipse. private void handle(final DocumentEvent e) { Document doc = e.getDocument(); try { String tex...

Testing graphics generation with JUnit

I'm using Java's Graphics2D to generate a graphical representation of a graph. I'm also using ImageIO to write a PNG file. (ImageIO.write(image, "png", out);) I'm wondering how should I write JUnit tests to test whether the generated graphics is what is expected. I could pre-generate the PNG files but what if the font is a bit different...

GWTTestcase accessing javascript object defined in an external javascript file fails

Hi, I have defined a GWT module that includes an external javascript file using tag. I have written a GWTTestCase that returns the above described module's name. When my testcase accesses a javascript object I see the following exception Caused by: com.google.gwt.core.client.JavaScriptException: (null): null Any idea on how to fix t...

junit can't find class:***Test

CLASSPATH:%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;%JUNIT_HOME%\junit.jar JUNIT_HOME:C:\Program Files\Java\junit3.8.2 In the cmd,I input:java junit.swingui.TestRunner junit.samples.AllTests ,however,it says :Class not found "junit.samples.AllTests" ...

Writing test code for verifying database entries when testing an API

I'm writing test code to test a client-server application. The application under test consists of an application that runs on Tomcat or another Java EE application server, and client jars that expose an API. I'm basically writing test code that uses this client API to connect to the server. In addition to extensively testing the ...

How to verify list of items in a test

I am writing a test case where I do send a list of Strings to be saved in the database. Then I will retrieve those from database and has to verify that everything is fine. I have written a assertNotNull(list) assertEquals(listSize, response.listSize()) However I want to verify the actual contents are also same. But my assertEquals ...

How can I use the Parameterized JUnit test runner with a field that's injected using Spring?

I'm using Spring to inject the path to a directory into my unit tests. Inside this directory are a number of files that should be used to generate test data for parameterized test cases using the Parameterized test runner. Unfortunately, the test runner requires that the method that provides the parameters be static. This doesn't work fo...

Is it possible to use java.lang.instrument.Instrumentation in JUnit tests?

Is it possible to use java.lang.instrument.Instrumentation in JUnit tests? I am using mockrunner to simulate a Servlet and want to measure the size of objects stored in a session ...

Test driven development: Void methods

I have been learning about TDD (using JUnit) and I have a doubt about how to go about testing void methods, in which case I can't directly use something like an assertTrue() on the return value of a method.. For example, say I have a simple console based application, and a part of it prints a menu on screen, say using this method: publi...

Which UnitTest framework to learn for Java now?

Hi all: Although I have programmed with Java for roughly 3 years + now (not day-to-day but at least I understand the fundamentals), haven't really come into the field of Unit Testing... My work is now more Testing / Problem Analysis oriented, so I reckon a good Java Unit Testing Framework will be quite helpful to this role. Obviously ...

Database cleanup after Junit tests

I have to test some Thrift services using Junit. When I run my tests as a Thrift client, the services modify the server database. I am unable to find a good solution which can clean up the database after each test is run. Cleanup is important especially because the IDs need to be unique which are currently read form an XML file. Now, I h...

what is difference between two methods

When we are doing unit testing with jUnit we write two methods setUp() and setUpBeforeClass() what is difference between these methods also between tearDown() and tearDownAfterClass @BeforeClass public static void setUpBeforeClass() throws Exception { } @AfterClass public static void tearDownAfterClass() throws Exception { } @B...

How to get Spring to autowire integration test class using multiple contexts?

One of my integration tests uses multiple Spring context files. It seems that Spring only autowires in beans from the first context and not the second. Does anyone know what I am doing wrong or how to work around the problem? @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:/META-INF/spring...

What testing framework for c# is the most similar to Junit 4?

Mainly from feature-set standing point, as well as similarity of method names/working logic/verbosity ? ...

Junit test of the same object

Hi i want to make a unit test suite on same object with same variable but different values But if the object get the same name (created by this.setName("testlaunch"); (who must have the name of a function launch by junit), it makes only one test. if i don't write this.setName("testlaunch"); he shout on me an [code]junit.framework.Assert...

Android app unit testing

So, I'm new to android unit testing. I'm trying to write a unit test for the Phone application: package com.android.phone; import android.content.Intent; import android.net.Uri; import android.test.ApplicationTestCase; import android.test.suitebuilder.annotation.MediumTest; import com.android.phone.PhoneApp; import dalvik.annotation....