junit

Running JUnit Tests on a Restlet Router

Using Restlet I have created a router for my Java application. From using curl, I know that each of the different GET, POST & DELETE requests work for each of the URIs and return the correct JSON response. I'm wanting to set-up JUnit tests for each of the URI's to make the testing process easier. However, I'm not to sure the best way t...

Relative path problem in ANT junit task

I have setup an ant script as eclipse builder to automatically run all my tests, like below: <project name="auto-test" default="test"> <property name="tst-dir" location="C:\STAF\services\custom\TopCoder\bin" /> <path id="classpath.base" /> <path id="classpath.test"> <pathelement location="D:\eclipse\eclipse\plugins\o...

Selenium - Store hidden variable

We are using Junit + Selenium to webtest our webpage. But we have run into a problem. I need to parse the value from a hidden field with Selenium. HTML of hidden field <input type="hidden" name="secretId" value="123456"/> I use the following XPath //input[@name='secretId']/@value I need to scrape that hidden variable and store it using...

Android AsyncTask testing problem with Android Test Framework

I have a very simple AsyncTask implementation example and have problem to test it using Android JUnit framework. It works just fine when I instantiate and execute it in normal application. However when it's executed from any of Android Testing framework classes (i.e. AndroidTestCase, ActivityUnitTestCase, ActivityInstrumentationTestCas...

Ending a JUnit Test

I have a "black box" of code that contains many threads. There is no method to "kill" the black box threads that I have found. I am passing data into the "black box" through junit and making sure that I am getting the expected outputs. Is there a way to gracefully exit the test case (It keeps it open in eclipse because of the threads ...

Method specific logging

Environment: JUnit 4, JDK 6 I would like to log all test names (annotated with @Test) and figure out the amount of time taken to execute each tests executed by JUnit in a standard J2SE environment. Should I rely on in-built JDK logging Logger.entering / exiting with System.currentTimeInMillis or is there a better way to do this. ...

Running single test case in Junit eclipse

Hi I am using junit for unit testing. I am using Eclipse. I have given 12 test cases that is 12 different functions. When I right click on the paticular function in Outline and give RunAS--->Junit Test it is executing all the test cases. How to overcome this ? I just want to run only one test case or one function !!! Any idea ? ...

Problem using JUnit4TestAdapter from eclipse plugin context

Hi! I am trying to create very simple eclipse plugin. I want to run current selected test case, using my tool with a help of JUnit4TestAdapter. When I run outside eclipse, using "main" with "parameters" everything is just fine. When I invoke "main" with the same "parameters" inside the eclipse (i am creating separate thread for tha...

No tests found with test runner 'JUnit 4'

Hello , my java test worked well from Eclipse ,I do not know I relaunch test from run menu and then have the following message: No tests found with test runner 'JUnit 4' In the .classpath file I have all jar files, and at the end have : <classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <...

junit4 test runner

my java test do not compile, I run it and have : no junit tests could not find main class (specified in run-configuration) ...

Starting Selenium with custom Firefox profile from Eclipse

Hi, I'm running Selenium tests from within Eclipse, but I can't load a custom Firefox profile. Most sources suggest I need to launch the Selenium Server like this: java -jar selenium-server.jar -firefoxProfileTemplate </path/to/template/> But when launching my test from within Eclipse it doesn't use that - the tests will run if the ...

How can I find out if code is running inside a JUnit test or not?

In my code I need to do certain fixes only when it is run inside a JUnit test. How can I find out if code is running inside a JUnit test or not? Is there something like JUnit.isRunning() == true ? ...

Upgrade eclipse 3.5(Galileo) JUnit

I would like to upgrade the JUnit version of my Eclipse Galileo (on windows) to JUnit 4.8.1 instead of the included JUnit 4.5. There does not appear to be a plugin update to use the new version or a way to change the location of the JUnit 4 jars. How can I update to the new version and/or use a JUnit jar not under the eclipse install di...

Trying to run Android JUnit tests in Ecclipse fails!

I have seen all the examples on the web and it seems real simple. I have a bare-bones app that displays a string. I have a a Android JUnit test project that I created when the app was being created (ecclipse asked if I wanted to create a test app). When I run the test app (Run As --- Android JUnit) I see the foolowing in the console.......

Google AppEngine + Local JUnit Tests + Jersey framework + Embedded Jetty

I use Google Appengine for Java (GAE/J). On top, I use the Jersey REST-framework. Now i want to run local JUnit tests. The test sets up the local GAE development environment ( http://code.google.com/appengine/docs/java/tools/localunittesting.html ), launches an embedded Jetty server, and then fires requests to the server via HTTP a...

Unit testing in Java - what is it?

Can you explain in a few sentences: Why we need it / why they make our life easier ? How to unit-test [simple example in Java] ? When do not we need them / types of projects we can leave unit-testing out? useful links ...

junit test suites

I have a script(test.bat) that allows me to launch one java test by command line : -java -cp() org.junit.runner.JUnitCore package.Class Now I want to do the same for several java tests ? how could I do it? should I have to add the byte code for each java test? could I have an example , please? ...

Netbeans: "Run -> Test Project" doesn't do anything.

Hello, everyone! I have many JUnit tests, which are all created by Netbeans' assistant (so nothing customized). I can run every test manually by doing "Test File" (Ctrl+F6). But when I use "Run -> Test Project", the message "No Tests executed" is displayed. Do I have to register every JUnit test somewhere? Or what could be the problem...

junit4 functions

how to create generic functions that could be called from each java test? In my function startappli I have : public class startappli{ public void testMain (String[] args) { String[] logInfos = new String[3]; logInfos[0] = (String) args[0]; logInfos[1] = (String) args[1]; } @BeforeClass public static void setupOnce() {...

Eclipse JUnit4: exclude tests using a name pattern

Is it possible to specify in the JUnit Run configuration in Eclipse a name pattern (say **/integration/*Test) that should be excluded from the test run when running all tests of a project? Looking at options in the Run/Debug Configuration I presume this question could be reduced to: is it possible exclude certain tests based on junit ru...