I have a Singleton/Factory object that I'd like to write a JUnit test for. The Factory method decides which implementing class to instantiate based upon a classname in a properties file ... |
I'm running some JUnit tests on my applications. Every test has a for loop calling respective method 10000 times.
The tested methods produce a lot of log.
These logs are also automatically ... |
There is a well-known debate in Java (and other communities, I'm sure) whether or not trivial getter/setter methods should be tested. Usually, this is with respect to code coverage. Let's ... |
I am currently using JUnit 4 and have a need to divide my tests into groups that can be run selectively in any combination. I know TestNG has a feature to ... |
I'd like to have it yell hooray whenever an assert statement succeeds, or at the very least have it display the number of successful assert statements that were encountered.
I'm using JUnit4.
Any ... |
I'm using IntelliJ-Idea to write Java daemons. We use JUnit to unit test our code and want to have automated runs on check-in to subversion.
Are there any tools available that can ... |
I have a bunch of JUnit 3 classes which extend TestCase and would like to automatically migrate them to be JUnit4 tests with annotations such as @Before, @After, @Test, etc.
Any tool ... |
|
I haven't looked at this in a while, but if I recall correctly both ant and maven still rely on JUnit 3 for unit tests (as of maven 2.09 the default ... |
In the setup method to a JUnit test case I'm working on I need it to run a sql script on my database before each test case, and then a rollback ... |
I don't know if I should test my @Entity-annotated Pojos. After all, there are mainly just generated getters/setters. Should I test them?
When it comes to testing DAOs I'm using all those ... |
In our project I have several JUnit tests that e.g. take every file from a directory and run a test on it. If I implement a testEveryFileInDirectory method in ... |
I wonder if it is a good practice to use JUnit's @Ignore. And how people are using it?
I came up with the following use case: Let's say I am developing ... |
I'm using Mobile JUnit, released by Sony Ericsson for unit testing for my J2ME project. I read in the documentation that one can run the tests under regular junit with the ... |
I'm using junit 4.4 and maven and I have a large number of long-running integration tests.
When it comes to parallellizing test suites there are a few solutions that allow me to ... |
How do I create test suites with Junit4? All the documentation I've seen doesn't seem to be working for me? And if I use the eclipse wizard it doesn't give ... |
In JUnit 3, I could get the name of the currently running test like this:
public class MyTest extends TestCase
{
public void testSomething()
{
...
|
I am currently using JUnit 4.4 and Java 1.6.x. And after a recent code fix, we started getting this AssertionFailedError in my JUnit tests on the method:
UtilityTest.testParseDate(4t): Mon Jan 15 09:26:07 ... |
Our application depends on numerous resources that are provided by another system.
To ensure the existence of those resources, we currently have a JUnit test case (probably more an integration test), that ... |
How do you test methods that fire asynchronous processes with Junit?
I don't know how to make my test wait for the process to end (it is not exactly a unit test, ... |
Is there a way to set my own custom test case name when using Parameterized tests in Junit4?
I'd like to change the default "[Test class].runTest[n]" to something meaningful...
|
I work on a project where we have to create unit tests for all of our simple beans (POJOs). Is there any point to creating a unit test for POJOs ... |
I am trying to get a test class compiling with JUnit, and I can't figure out why it will not compile.
I have the following lines at the top of my class:
import ...
|
I've got 2 questions about organising Unit tests.
- Do I have to put test to the same package as tested class, or can I organise tests in different packages?
For example if I ...
|
Is there any way to group tests in JUnit, so that I can run only some groups?
Or is it possible to annotate some tests and then globally disable them?
I'm using JUnit ... |
The following class serve as generic tester for equals/hashCode contract. It is a part of a home grown testing framework.
- What do you think about?
- How can I (strong) test this class?
- It ...
|
I have been trying to find a tool similar to JUnit Max for Visual Studio.
Preferably, the tool would work with Visual Studio 2008 Professional and NUnit.
For those who are ... |
I'm familiar with the use of Parameterized tests in JUnit, e.g:
http://junit.org/apidocs/org/junit/runners/Parameterized.html
but I wondered whether there were any alternative (possibly better) approaches to externally defined test data. I don't ... |
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 ... |
Been hitting my head on the wall before as I don't make any test classes while using c/c++ (but instead have a lot of print methods).
What is the most used method ... |
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 ...
|
I need to write JUnit tests for an old application that's poorly designed and is writing a lot of error messages to standard output. When the getResponse(String request) method behaves correctly ... |
Is there an equivalent to C#'s 'new' modifier in Java?
I'd like to use it for unit tests - every init() method should be marked final and annotated with @Before. ... |
I have been working on a comparatively large system on my own, and it's my first time working on a large system(dealing with 200+ channels of information simultaneously). I know how ... |
I have the following test case in eclipse, using JUnit 4 which is refusing to pass. What could be wrong?
@Test(expected = IllegalArgumentException.class)
public void testIAE() {
throw new IllegalArgumentException();
}
This ... |
Checking function takes two arguments, I want to have a testcase for each element of the cartesian product of the respective domains, but without manually writing all the test cases like ... |
I'm working on a project at the moment that we're using junit to test, but as its still fairly early stages a lot of features aren't yet implemented, though they already ... |
I have the classical structure for tests, I have a test suite of different suites like DatabaseTests, UnitTests etc. Sometimes those suites contains other suites like SlowDatabaseTests, FastDatabaseTests etc.
What I want ... |
I have maven configured to run gunit (an ANTLR grammar unit testing tool) through the maven-gunit-plugin. gunit, however, has two different modes. The first mode ... |
My setup:
Netbeans 6.7
Java6
JUnit 4.5 added as the Test libraries
When I try to pass in two class arrays (cast as Object[]) I get the error "cannot ... |
I am using Struts2, Spring 2 and Junit 4.5.
My main question is, whether even to test REST calls? Because, basically this are only calls to business logic and they don't have ... |
Let me describe a simple use-case:
Running all tests in our project may take up to 10 minutes.
Sometimes I see an obvious bug in my code after the first failed test, so ... |
I have a JUnit test that fails because the milliseconds are different. In this case I don't care about the milliseconds. How can I change the precision of the ... |
I've got JUnit hooked up with CruiseControl and unit tests are being executed & logs imported, but CruiseControl shows the following output:
nz.co.picksend.core.tests.nz.co.picksend.core.dal.FilterTests
Tests: 0, Failures: 0, Errors: 0, Duration: 0.0
nz.co.picksend.core.tests.nz.co.picksend.core.dal.ModelObjectRegistryTests
Tests: ...
|
OK, so the @Ignore annotation is good for marking that a test case shouldn't be run.
However, sometimes I want to ignore a test based on runtime information. An example might ... |
I have not used Junit before and have not done unit testing automatically.
Scenario:
We are changing our backend DAO's from Sql Server to Oracle. So on the DB side all ... |
I'm familiar with aggregating junit test results within a single build, but are there any tools that let you aggregate results across different builds?
I'd like to discover which tests failed most ... |
I noticed that jUnit runs the constructor of my test class for each method being tested. Here's an example:
public class TestTest {
protected BigUglyResource bur;
...
|
I have a number of JUnit test cases that are currently not documented with Javadoc comments.
The rest of my code is documented, but I'm wondering if it's even worth the effort ... |
I've noticed that when importing JUnit, the * wildcard doesn't always work.
e.g. for the annotation @Test you must import org.junit.Test since org.junit.* doesn't recognize the annotation.
Is there a reason for this, ... |
What do you use for writing data-driven tests in jUnit?
(My definition of) a data-driven test is a test that reads data from some external source (file, database, ...), executes one test ... |
I'm learning JUnit. Since my app includes graphical output, I want the ability to eyeball the output and manually pass or fail the test based on what I see. It should ... |
I was surprised not to find the answer so far. If I am missing something basic I will be more than happy to know that.
There is a large legacy code base ... |
I want to test validation logic in a legacy class. The class uses a method to load effective dates from a config file.
I have written a subclass of the class ... |
I am trying to make unit tests for multiple return values in Antlr. I have regular unit tests working using gunit. However, I am not too sure what to do with ... |
I would like to execute JUnit on a remote machine hosting a JVM embedded and linked to a C application through JNI. This JVM has state and access to live external ... |
When using this approach below, by setting up the jUnit with Suites. We got the problem when all @BeforeClass in every Testclass will be executed before any tests starts to execute.
(For ... |
If I have a basic accessor method that returns an ArrayList
What exactly would i test for it?
I am very inexperienced when it comes to testing.
|
My Junit test should check that the number being returned is the same as the list size
if my test was as follows would this be coded properly, i feel it isnt ... |
I would like to compile JUnit from windows command line.
I have a project that contains many different packages. I can compile and run this project from the command line. However, I ... |
When I run javadoc on my java source code, I get this error for th Junit test class:
[javadoc] /mypath/TestStuff.class: warning: Cannot find annotation method 'expected()' in type 'org.junit.Test': class file for ...
|
I have a standalone singleton which successfully passes the test. But with a group of tests this fails since once a singleton is defined it does not allow to reset the ... |
When I run JUnit tests failures cause very large stack traces that don't really provide much information. I would like to be able to just see the failing assert statement, so ... |
Does anyone have an example of using Apache Qpid within a standalone junit test.
Ideally I want to be able to create a queue on the fly which I can put/get msgs ... |
JUnit 4.8 contains a nice new feature called "Categories" that allows you to group certain kinds of tests together. This is very useful, e.g. to have separate test runs for slow ... |
I cannot get Maven Surefire to execute my JUnit 4 tests even after I tried all the advices from another post.
My POM:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
...
|
i would like to ask you about writting tests which are connected with data from database. In my opinion the best way is to have a diffrent DB schema with correct ... |
I'm looking for a JSON paring library that supports comparing two JSON objects ignoring child order, specifically for unit testing JSON returning from a web service against an expected value.
Do any ... |
I have an abstract testcase "AbstractATest" for an interface "A". It has several test methods (@Test) and one abstract method:
protected abstract A unit();
which provides the unit under testing. No i have ... |
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 ... |
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 ... |
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 ... |
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[] ...
|
I am beginning with JUnit and do not understand the annotations @Test and @BeforeClass.
I have the following code:
public class Toto {
@BeforeClass
public static void setupOnce() {
...
|
When I try to use assertNotLesser or assertNotGreater I get compile error .. and eclipse suggest me to create a new method called like this .. http://junit-addons.sourceforge.net/junitx/framework/ComparableAssert.html I ... |
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 ... |
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 ... |
I'm writing some acceptance tests for a java webapp that returns JSON objects. I would like to verify that the JSON returned validates against a schema. Can anyone suggest any tools ... |
I'm currently building a CI build script for a legacy application. There are sporadic JUnit tests available and I will be integrating a JUnit execution of all tests into the ... |
As title says, im having trouble with my junit tests passing for checking if a character is not in a string and how to check if an empty string doesnt have ... |
Simple question :)
How can I reduce build time using a parallel build / parallelizing the tests?
We're using TeamCity, JUnit, Fit, Selenium
|
Quick JUnit question. I'm running some unit tests that involve starting up the GUI and doing a load of stuff.
I would like to see the results after the test to confirm ... |
Is it possible to run JUnit tests from inside my java application?
Are there test frameworks I can use (such as JUnit.jar?), or am I force to find the test files, invoke ... |
How do you mock-up/trick the JVM to get a date other that the current system date? I have a set of tests in JUnit I don't want to change, but instead ... |
I have the piece of code that reads data from file. I want to force IOException in this code for testing purpose (I want to check if code throws correct custom ... |
Our toolkit has over 15000 JUnit tests, and many tests are known to fail if some other test fails. For example, if the method X.foo() uses functionality from Y.bar() ... |
I was told to create a tool like a Nightly Builder for a JUnit project. It's a client-server project with oracle database.The tests are based on QTP. Also there is a ... |
Strangest thing happened my test was running ok and now its not anymore I didn't change the code at all here is the exception :
Class not found com.example.test
java.lang.ClassNotFoundException: com.example.test
...
|
Normally I would have one junit test that shows up in my integration server of choice as one test that passes or fails (in this case I use teamcity). What ... |
I was wondering how to run some JUnit4 test inside a java program. Basically - depending on some conditions during runtime I need to decide which test runner to use. Using ... |
I have a test class that I'm trying to run from a main method with the folowing code :
Result r = org.junit.runner.JUnitCore.runClasses(TestReader.class);
when I examine the Result object I can see ... |
OK, so I work for a company who has openly adopted agile practices for development in recent years. Our unit tests and code quality are improving. One area we ... |
I'm looking for a way to access a POP3 account while running a JUnit test. Does anyone know how to do that? I probably need some kind of library for POP3 ... |
I was testing a String multiplier class with a multiply() method that takes 2 numbers as inputs (as String) and returns the result number (as String)
public String multiply(String num1, String ...
|
I'm creating a TemporaryFolder using the @Rule annotation in JUnit 4.7. I've tried to create a new folder that is a child of the temp folder using tempFolder.newFolder("someFolder") in the @Before ... |
I use embedded servers that run inside Junit test cases. Sometimes these servers require a working directory (for example the Apache Directory server).
The new @Rule in Junit 4.7 can handle these ... |
I am trying to run JUnit test with a 1.5 JRE, but get the error Message:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
When I switch to JRE 1.6 (actually a JDK but ... |
Is JUnit the best unit testing framwork? Which framework is best for new java projects?
|
I understand that there are @Before and @BeforeClass, which are used to define fixtures for the @Test's. But what should I use if I need different fixtures for each @Test?
|
I m facing a issue where test/resource is not picked,but instead jar's main/resource is picked
Scenario is like : Myproject
src/test/resources--- have config.xml w
which should be needed by abc.jar which is a dependecy ... |
JUnit 4.7 introduced the concept of custom rules:
http://www.infoq.com/news/2009/07/junit-4.7-rules
There are a number of built in JUnit rules including TemporaryFolder which helps by clearing up folders after a test has been ... |