Using Guice, is it a good practice to get a new injector in each JUnit test class, as each test class should be independant?
|
I need good examples of Junit tests for Java classes, to spend in training, anyone have suggestions of good examples?
|
i have a question about testi toString construct in a Java class: give a toString method:
public String toString()
{
String accountString;
NumberFormat money = NumberFormat.getCurrencyInstance();
...
|
What is the difference between a Theory and a Parameterized test?
I'm not interested in implementation differences when creating the test classes, just when you would choose one over the other.
... |
How do you manage resource clean up in JUnit4 (in a JUnitRunner / in a TestCase) when you interrupt the test in debug mode ?
I use Selenium WebDriver by implementing JUnit ... |
How can I test the following method with parameterized testing in Junit
public class Math {
static public int add(int a, int b) {
... |
Without looking into JUnit source itself (my next step) is there an easy way to set the default Runner to be used with every test without having to set @RunWith on ... |
|
I have an app that manages turns in a game, it's fairly complex and it has a lot of timers that generate timeouts.. since they interoperate a lot it's difficult to ... |
I have some old code that I would like to test using Junit. After importing it into Eclipse it looks like this:
After this, I try to ... |
Chris has written a function called toBinary that has an input parameter of an integer number and returns a string that represents the binary equivalent. For example, if the function is ... |
I am trying to integrate SoapUI into my preexisting JUnit tests. I have created a test in SoapUI 3.6.1. It works.
My next step is to apply it to my ... |
When jUnit runs a test suite containing multiple "sub suites", is it possible to filter tests found in different suites as to make them run only once? I'm working on a ... |
I have this method
public String getNum(int x) throws Exception
{
if(x == 0){
throws new Exception("x cannot be 0");
...
|
I am writing unit tests for objects that are cloned, serialized, and/or written to an XML file. In all three cases I would like to verify that the resulting object is ... |
I have implemented two static void methods which create files and read files.
And I want to test the methods but I don't know how to test methods which work with files.
What ... |
I'm using JUnit 4. I can't see the difference between initializing in the constructor or using a dedicated init function annotated by @Before. Does this mean that I don't have to ... |
I'm working on an application which has a grid and only some points of the grid are considered valid. I need to test this extensively with all possible grid values or ... |
I'm trying to write a test for the following method:
public class Sort {
...
...
...
public static String[][] findRanks(String[][] array, int indexOfPoints, int indexOfRank) {
...
|
I am implementing some tests for an existing Java Swing application, so that I can safely refactor and extend the code without breaking anything. I started with some unit tests in ... |
I am using unitils (and its dbMaintain module) to maintain the state of my local database.
dbMaintain has an option to exclude/include scripts based on a qualifier. See |
Can somebody please tell me how to integrate java JUnit with TeamCity?
|
I would like to test an API, which received one argument and returns a set. The test invokes the API with an argument and checks if the returned set contains ... |
Tomorrow, I will be taking up my first job as a software engineer. I am doing an internship as a Software Test Engineer doing black box and white box testing. ... |
What is the proper way with JUnit 4 to create test cases to use common functionality: e.g. setup that is common to several unit test classes? What I did was ... |
Say I have a method that returns a collection of Animals. In one case I want to check that this method contains exactly 7 Dogs. Checking the number isn't a problem, ... |
I have this problem in testing assertArrayEquals in JUnit as I am not sure how it works. I created a method so I can understand it but its not working. Can ... |
We currently have a dedicated tool for running system tests on our web services, but I've been thinking of re-writing it to be hostable within jUnit4.
This would give us several advantages, ... |
I'm working on fixing a JNI call that's crashing at the moment. Striving to be a good TDD practitioner, I've created a JUnit test to replicate the problem, which it ... |
I am reading an external log file via xslt, and i want to find a certain line.
Once i find it, i want to print all the lines until i hit another ... |
public Integer getCancelStatusForMacId (String macAddress){
if (logger.isDebugEnabled()) {
logger.debug("getLinkIdByPartnerSiteId Begin ");
...
|
|
I'm writing Junit test cases for a bunch of classes; each of them has a handful of method to test. The classes Im about to test look like the following.
class A{
...
|
I am trying to run a very simple functional test using HTMLUnit:
public void testHomePage () throws Exception{
final WebClient webClient = new WebClient();
assertEquals(1,1);
...
|
In JUnit tests, I need to test that a given object (not the reference, but the attributes of the object) is not in a list. What's the best way to do ... |
I'm trying to use findbugs as a library for my program (but the problem is not strictly related to findbugs). I've wrote several tests to configure and call some ... |
I am new to JUnit and I got a sample java project in which I need to write unit tests for all the methods.
Unfortunately the code is poorly designed and some ... |
I was wondering is there any way in Java to force a stale connection?
We have some logic that determines if a sqlexception received is actually a Stale Connection - if it ... |
What is the best approach to write unit tests for code that persists data to nosql data store, in our case cassandra?
=> We are using embedded server approach using a utility ... |
I have been given the tasks of re-organization and documentation of a bunch of JUnit tests, about 1800, that have very little documentation and are not organized very well. Does ... |
Are there any alternatives to JUnit? I have a head unit running a proprietary stripped down version of JRE 1.4.2, and JUnit is incompatible with this implementation.
|
My program needs to interact to a directory (with a hierarchical structure) a lot and I need to test it. Therefore, I need to create a directory (and then create sub ... |
I have a question about JUnit testing.
Our JUnit suite is testing various functions that we wrote that interact with our memory system.
The way our system was designed, requires it to be ... |
I'm trying to come up with an efficient way to index my JUnit test, and hopefully come up with some automated way to do it.
Right now, I've got a JUnit Text ... |
Could someone describe in a few words what the main differences between JUnit 3 and 4 are?
Thanks in advance...
|
I have been assigned the task of unit testing a class that I never worked directly on with JUnit, and am strictly forbidden to change the code in the package. ... |
What is the best way to write junit tests for interfaces so they can be used for the concrete implementing classes?
e.g. You have this interface and implementing classes:
public interface MyInterface {
...
|
I'm working on a project with a lot of plsql code and would like to add more specific unit-tests to our codebase. Some of the procedures/functions I like to test aren't ... |
Is there way to define a different teardown for each @Test in jUnit?
|
Is it possible to group DataPoints by something other than their type?
For example, suppose I have a Theory that I want to test, using "age" and "weight" as parameters:
@Theory
public void testSomething(int ...
|
I need to define a system property for my JUnit tests. I've tried various steps to pass the name/value pair into gradle. (I've tried Milestone-3 and 4).
None of these approaches ... |
I am new to JUnit . I am working on the ways to get a output like
classname / function name / status / description.
I figured that there is no other ... |
How can I enforce that my test class covers a particular interface?
Also is there a convention for writing overloaded test methods, so the names are consistent (my current technique is ... |
I'm using JUnit 4 (junit-4.8.2.jar) to run tests on my Java project and am running into problems when using assumeTrue. I have this basic set up:
public class ClientTest extends TestCase ...
|
I am creating some unit tests for an app that uses a REST API. When I try to send a HttpPost request to the server URL (https://some.server.com), I got this:
javax.net.ssl.SSLPeerUnverifiedException: peer ...
|
I would like to consolidate all my jUnits onto a single web portal (like fitnesse) and build them every night for a consolidated report. Are there any opensource tools available for ... |
What is difference between tearDownClass() & tearDown() methods?
Where can I find documentation for both.
junit.org documentation of JUnit listed only tearDown() not tearDownClass():
... |
We are in the process of upgrading our J2EE application from jdk1.4 to jdk1.6 along with moving to a different application server. Yes, lots of moving parts. However, I had written ... |
I would like to do something like:
@RunWith(Categories.class)
@Categories.IncludeCategory(Small.class)
@Categories.ExcludeCategory({Manual.class, NonFunctional.class})
@Suite.SuiteClasses(AllTests.class)
public class SmallTests {
}
but ExcludeCategories accepts only one class, not an array of classes.
|
I'm pulling my hair out getting JDEE set up.
I've finally got the prj.el file to the point where I can run Ant tasks and I can do compiles of src .java ... |
This is a pretty dumb question but my first time with unit testing so:
lets say I have an object variable like obj and I want my unit test to Fail if ... |
I am facing the following problem while running it using junit: All the methods are working fine except testValidatePanelistIDHwid. This is the new method that i have added in this class ... |
I would like to run a series of integration tests against a system. I would like to ditch the boilerplate @Before and @After code that just involves getting and releasing a ... |
I've similar questions asked on this site, but this is a bit of a different scenario than what I have seen.
We have a PC client execute JUnit 4 tests. However, we ... |
import java.util.regex.Pattern;
public class TestUI {
private static Pattern p = Pattern.compile("^[A-Za-z0-9()+-]+$");
public static void main(String[] args) {
// TODO Auto-generated method stub
//Test case1
String[] str=test();
System.out.println(str[0]+str.length);
match("Alphanumeric(Text)");
}
private static String[] ...
|
I would like to pass arguments to my JUnit tests from run configurations. How do I reach to JUnits main method to access to those args? Anybody knows how to do ... |
I have to run junit test from command line and one of the guy in the team created junit classes like below:
public Test extends TestCore
{
String some;
...
|
In the past I would make a test suite per package, that would hold all of the tests in that package.
then I would roll up all of the package test suites ... |
I'm doing a simple assignment that reads user input from System.in, but then it suddenly occurred to me that the assignment requires me to create jUnit test cases to confirm that ... |
I need to insert data into a table using JUnit tests. Is this possible? If so, how? Thanks!
|
Suppose you have a method like
public Something copy () {
return new Something();
}
In your jUnit, you have
Something s1 = new Something();
Something s2 = s1.copy()
Other then
assertTrue (s1 != s2);
assertTrue (s2 ...
|
For using Emma we'll first instrument the jar using Emma. During that time em metadata files will get generated and when you run the JUnit test cases over the instrumented jars ... |
I am trying to write parameterize test in JUNIT4 and I don't know how to make multiple parameters for instance :
@parameter1
{1,2,3,4}
@test1
run test using @parameter1
@parameter2
{3,55,66,77}
@test2
run test using @parameters2
Could anyone provide me with ... |
@DataPoints public static final Integer[] input1={1,2};
@Theory
@Test
public void test1(int input1){
}
@DataPoints public static final Integer[] input2={3,4};
@Theory
@Test
public void test2(int input2 ){
}
I want that test1 runs with data set input1 - {1,2} and test2 runs ... |
What apps would you use? Are there auto testing suites like autotest for ruby? What do you use and why? To be honest, I don't even know how to write ... |
Is there a way to get a list of the jUnit tests that were run for the purpose of including that list in a report?
Rather than copying the 80 unit tests ... |
How can one make contributions to JUnit or any other open source java framework in general? I am a entry level programmer and any suggestions are welcome.
|
How can we use xmldatasource in junit test? I am using spring and hibernate in my application
I have created xmldatasource using Eclipse Database View.
Thanks,
Bhupendra Kalakoti
|
I have a test and I want that it should not be launched
what is the good practice : set Ignore inside test? @Deprecated?
I would like to not launch it but ... |
So I've read the official JUnit docs, which contain a plethora of examples, but (as with many things) I have Eclipse fired up and I am writing my first JUnit test, ... |
According to the SourceForge project page, junit-addons is compatible with Junit 3.7 and 3.8. Does anyone know if this will work with Junit4.x? If not, are there any alternative ... |
I am designing a java server to respond to multiple client requests. So the design basically has a server socket, accepts a client socket, creates a inputObjectStream and a outputObjectStream from ... |
I am writing tests for an interpreter from some programming language in Java using JUnit framework. To this end I've created a large number of test cases most of them containing ... |
I am dealing with a case where my tests pass or fail based on the order of declaration. This of-course points to not properly isolated tests. But I am stumped about ... |
I have a code which retrieves few information from Database.
For example if you pass person Id, method will return you person details like:
Name: XXX X XXX
Address: XXXXXXXXXXXXX XXXXX
Phone: ... |
I have some JUnit tests that use the TemporaryFolder @Rule. They use the TemporaryFolder in a @Before method to perform some setup:
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Before
public void init() {
...
|
I already run fitnesse suites outside of the fitnesse server using a test class of the form:
@RunWith(FitNesseSuite.class)
@Name("FitNesse.MyAcceptanceTestSuite")
@FitnesseDir("src/it/resources")
@OutputDir("target/fitnesse-results")
@DebugMode(true)
public class JavaFitNesseSuiteIT {
//
}
I've managed to get fitlibrary running on my ... |
A little background, I'm hitting a situation where I haven't been able to enable assertions (asked here) and using a great solution like forceassertions is not possible for ... |
I have a test case that provides arguments and executes the main method of a class. What would be the best approach using Junit to have multiple threads concurrenlty execute the ... |
Good day everyone,
I tried searching, but failed to find the answer.
I have a lot of unit tests files that basically execute the same @BeforeClass.
They start jetty web server, add ... |
A newbie to JUnit (in fact JUnit 4) and came across suite way of executing test
@RunWith(Suite.class)
@Suite.SuiteClasses(
{ ...
|
I need to test SSO using Webseal. I'm not even close to being able to get access to the Webseal itself (client site installation).
My JAVA code is very simple:
String userId = ...
|
Seems like there's no answer on the internets. All I need is to concoct an SConstruct that does two things:
- runs JUnit
- produces reasonable output for CruiseControl to display
|
I am writing a Junit test that will test certain java classes. These classes heavily use the FlexContext and FlexSession and assume that all the requests are coming from the Flex ... |
I have tried to follow this steps.
But when I try to run multiple scenarios in the same file, my jUnit seems to be completely lost. It runs a ... |
I am using Junit for the first time in a project and I'm fascinated by the way it is forcing me to restructure my code. One thing ... |
The title pretty much says it all but I will clarify anyway.
I have a jUnit test (lets call it T1) in which I use an assertion. For that assertion to be ... |
One of my JUnit tests is giving me a NullPointerException and I can't figure out why.
This is the contents of the test class, PacketWrapperTest:
/**
* Mock Node for Packet A.
*/
private ...
|
I believe functional testing is testing of two or more modules together with the intent of finding defects, demonstrating that defects are not present, and verifying that the module performs its ... |
I am trying to customize a runner for junit. I am using the Extended runner given here:
http://codehowtos.blogspot.com/2011/04/run-junit-test-repeatedly.html
adding my own created Filter Runner's code, which extends Runner, to the ExtendedRunner ... |
I am involved with a project which must, among other things, controlling various laboratory instruments (robots, readers, etc...)
Most of these instruments are controlled either through DCOM-based drivers, the serial port, or ... |