unit test « unit test « Java Testing Q&A

Home
Java Testing Q&A
1.Development
2.FindBugs
3.HTMLUnit
4.hudson
5.junit
6.performance
7.plugin
8.profile
9.selenium
10.Tools
11.unit test
Java Testing Q&A » unit test » unit test 

1. Should domain objects and simple JavaBeans be unit tested?    stackoverflow.com

Should simple JavaBeans that have only simple getters and setters be unit tested?? What about Beans with some logic in getters and setters?

2. What is the best framework for Unit Testing in JavaME?    stackoverflow.com

What is currently the best tool for JavaME unit testing? I´ve never really used unit testing before (shame on me!), so learning curve is important. I would appreciate some pros and ...

3. How should one unit test the hashCode-equals contract?    stackoverflow.com

In a nutshell, the hashCode contract, according to Java's object.hashCode():

  1. The hash code shouldn't change unless something affecting equals() changes
  2. equals() implies hash codes are ==
Let's assume interest primarily in immutable data objects ...

4. How to reinitialize static finals while unit testing    stackoverflow.com

I am writing unit tests for a class, which has a static final variable. However, since the state of the static final var is modified in each test, I need some way ...

5. How do you make a unit test when the results vary?    stackoverflow.com

I am building an application that queries a web service. The data in the database varies and changes over time. How do I build a unit test for this ...

6. Where can I find unit tests for Sun classes?    stackoverflow.com

I'm writing an implementation of an interface provided by Sun and I'm wondering if anyone knows of the availability of unit tests for Sun's APIs. It would seem that such of thing ...

7. Dumping "real-world" scenarios out for unit testing    stackoverflow.com

I'm currently debugging some fairly complex persistence code, and trying to increase test coverage whilst I'm at it. Some of the bugs I'm finding against the production code require large, and very ...

8. Balancing Design Principles: Unit Testing    stackoverflow.com

I am writing a simulation of Bananagrams. Currently, I have a GameMaster class that maintains the common collection of pieces. The deal(Player) method deals a certain number of pieces to that ...

9. Unit testing for downloads    stackoverflow.com

I am writing a Java program that downloads and then processes many webpages. What is the best practice for testing a component of the program that downloads a page without ...

10. Automatic generation of unit tests for Java?    stackoverflow.com

Any tool for automatically generating unit tests for Java code? UPDATE: Primary intended use is to quickly generate unit tests for legacy code that is going to be refactored. No need to ...

11. Java Card Unit Testing    stackoverflow.com

I'd like to run my Java Card applications in some kind of emulated/simulated environment to be able to run JUnit (or any other unit test framework) tests on them. ...

12. Framework or tool for "distributed unit testing"?    stackoverflow.com

Is there any tool or framework able to make it easier to test distributed software written in Java? My system under test is a peer-to-peer software, and I'd like to perform ...

13. Sensible unit test possible?    stackoverflow.com

Could a sensible unit test be written for this code which extracts a rar archive by delegating it to a capable tool on the host system if one exists? I can write ...

14. Xml Dom library with unit tests    stackoverflow.com

Googled for a Xml Dom open source library that ships with unit tests, but could not find any. Are there any dom libraries, java or .net that have unit tests?

15. How does Java ServiceLoader work during development time? (Unit test before building JARs?)    stackoverflow.com

Java's ServiceLoader needs those entries to be present inside the JAR file. Is there a way to programatically add those service entries at runtime time for unit testing, when inside the ...

16. Unit testing mathematical code    stackoverflow.com

I am writing a small utility for calculating a complicated mathematical formula (using commons-math library for integration and root finding). I was trying to write it in the same way as ...

17. Unit tests must locate in the same package?    stackoverflow.com

A JUnit book says " protected method ... this is one reason the test classes are located in the same package as the classes they are testing" Can someone share their experience ...

18. How to write unit test for "InterruptedException"    stackoverflow.com

In attempts of 100% code coverage, I came across a situation where I need to unit test block of code that catches an InterruptedException. How does one correctly unit test for ...

19. Java Unit Testing    stackoverflow.com

I have a program and I am trying to write my Unit Test for it, I just need to know if it is correct? Here is the program:

public static int[] ...

20. Java Unit Testing    stackoverflow.com

I am trying to do some Unit Testing on my program and I need to test if an array is equal to another array so I need to write the code ...

21. How to organize unit tests for a complex class?    stackoverflow.com

I have a complex class (300+ lines), which I'm trying to test from different "points of view". I've already created three different unit tests. Every test is a complex class itself ...

22. Classification of Unit Testing    stackoverflow.com

Assume I have built a MVC web apps written using Java. Now I want to write unit tests for the web apps, what kind of unit testings should be done for a ...

23. Does this unit test have to be in the same package as the controller it tests?    stackoverflow.com

According to this example, it goes in the same package as the controller it tests. Why is that necesssary? I think it would be tidier to have all of my ...

24. What are the unit testing frameworks available in java?    stackoverflow.com

What are the technologies out there? (I only know of JUnit) What is the most popular? Can you please explain the pros/cons of each? Thanks Alot!!

25. How to unit test a spreadsheet parser?    stackoverflow.com

I have a DeliveryScheduleParser class that reads in a spreadsheet and parses it into a number of objects that all end up in a client object that is returned by the ...

26. How to unit test immediate exit of method    stackoverflow.com

How to unit test the following piece of code:

@Override
public void update() {
  if (isStopped() || isPaused()) {
    return;
  }
  // ...
}
This method is from an ...

27. unit testing java application [beginner level]    stackoverflow.com

As part of a Java assignment i have written a Payroll program. The programm generates 2 files: payslip and report. The payslip contains all the details for each employee e.g. name, ...

28. Minimizing object retention during unit tests    stackoverflow.com

I have a question about memory management/memory leaks that I would like clarification on. Set Up: I am testing some servlet code that takes HttpServletRequest and HttpResponse objects references HttpServletRequest#getParameter(String), HttpServletRequest#getHeader(String) and HttpServletRequest#getAttribute(String). I ...

29. unit testing - advice needed    stackoverflow.com

i have spring project that consists of a parent and few child projects. the build is maven-based and the continous integration server is hudson. i need to choose the way the unit tests ...

30. How can I get the unit test cases that the developers of the JDK performed on the JDK classes?    stackoverflow.com

How can I get info about unit test cases that the developers of the JDK performed on the JDK classes?

31. Automating unit test cases in java    stackoverflow.com

Referred this question first. But seems my context is different. I'll try to be short and simple. (Just the code I'm putting out is quite big ;) I have some ...

32. Unit Testing Similar Functions    stackoverflow.com

I have setter functions that check their input data by passing it to a validation function before changing private variables. If the data is invalid, the getter functions throw an exception. ...

33. What JUnit-style frameworks are available for unit testing PL/SQL in Oracle?    stackoverflow.com

I'm looking to introduce automated unit testing to a large body of existing Oracle PL/SQL functions, procedures, and types. I would like to use an existing framework that is conceptually as ...

34. Should unit tests use logging?    stackoverflow.com

There seems to be two trends on this topic:

  1. Some answers (such as this one) suggest unit tests should not log anything.
  2. Some questions and answers (such as this one) suggest ...

35. Unit testing examples that proves that unit tests are worth writing    stackoverflow.com

I have read a lot about unit testing, but I still haven't found any good examples that would show why unit testing is worth the time. I would like to see actual ...

36. What is the preferred approach with regards to unit testing and dates?    stackoverflow.com

I have a class which calculates a date and I'm wondering how best to test this. I've come up with two approaches and wonder about your thoughts on which is ...

37. How to do unit test without emulator with MockME?    stackoverflow.com

I am doing some J2ME API test and I found MockME seems like a perfect tool for me, but I didn't found much tutorial about this framework and It seems not ...

38. New unit testing framework for Java    stackoverflow.com

I'm looking into new frameworks to perform some unit testing on a java project. I am aware of junit, but beyond that I haven't found much of consequence. Are there any ...

39. Naming unit test methods of overloads in Java    stackoverflow.com

What is the most accepted way to name a unit test method when the target has overloads. Consider these methods:

doSomething();
doSomething(String);
How would you name the corresponding test methods? Would this be the ...

40. What's the best way to unit test a cfc that uses a Java object for a lot of its functionality?    stackoverflow.com

I have a cfc that relies heavily on a Java object (created via JavaLoader) for a lot of its core functionality that I'd like to write some tests for and I'm ...

41. Reducing responsibilities and Collaborators for Unit Testing    stackoverflow.com

I have a class which has a well-defined responsibility - to "Enrich" an object with the information it needs. This information is gathered from a variety of sources (Services). Eg:

public class ...

42. Unit testing for object immutability    stackoverflow.com

I want to make sure that a given group of objects is immutable. I was thinking about something along the lines of:

  1. check if every field is private final
  2. check if class is final
  3. check ...

43. How to write a unit test framework?    stackoverflow.com

  • How to write a unit test framework?
  • Can anyone suggest some good reading?
I wish to work on basic building blocks that we use as programmers, so I am ...

44. How to unit test callback logic?    stackoverflow.com

More complete question is, given a dependency that expects a callback as a parameter, how do I write a unit test that covers the callback logic and still manage to mock ...

45. how to write unit test for retrieving items from a java Set    stackoverflow.com

I have implemented a ShoppingCart where the CartItems are put in a Set to avoid duplicate items. I want to test putting items in cart and persisting in db, and then ...

46. Simple equation fails unit test    stackoverflow.com

I have method that takes 2 integers as arguments and returns:

 public int method(int a, int b){
   return Math.round((Math.abs(a-b)/3) - (Math.min(a,b)-1500)/10)
 }
I have created unit test, which passes for ...

47. Unit testing when the output is a wall of text    stackoverflow.com

I am currently testing a part of my application (that we will assume is a class named X) that takes as parameter a reflection java Method, and will print some java ...

48. C/C++ Unit test tool?    coderanch.com

49. unit test    coderanch.com

51. Unit Testing Front Man Commands    coderanch.com

52. How to design using unit test    coderanch.com

How to design using unit test (Java in General forum at JavaRanch) A friendly place for programming greenhorns! Register / Login Java Forums Java Java in General How to design using unit test Post by: John Vorwald, Ranch Hand on Nov 19, 2011 08:18:52 I'm not very good at applying unit testing early in the process, I tend to ...

54. Getting a nullpointer with unit testing    java-forums.org

public boolean gotoStartPosition(Player player) { boolean returnBool = true; if (player!=null){ for(Chest chest : playground.chestList) { if((chest.getXIndex() == player.getXStart()) && (chest.getYIndex() == player.getYStart())) returnBool = false; } if((player.getXIndex() == player.getXStart()) && (player.getYIndex() == player.getYStart())) returnBool = false; if(returnBool == true) { player.setXIndex(player.getXStart()); player.setYIndex(player.getYStart()); player.setNumberOfSteps(player.getNumberOfSteps()+5); } return returnBool; } else{ System.out.println("The player class is not instantiated"); } return returnBool; }

55. unit test failure    forums.oracle.com

/** * Divide this mony object by the other money * object to produce a dimensionless ratio.For example: * * Money first, second; * * Money result = first.div(second); * * is similar to: * * double first, second; * * double result = first / second; * * @param other the money object to divide into this one. * @return ...

56. unit test code gen?    forums.oracle.com

Folks, I've been tasked with creating test cases for the EJB's of some new functionality. So... I sat down to specify what test cases will be required. It wasn't long before I realised the amount of repetative "boiler plate" code we'd be writing to: * test what every reference-type argument to every EJB method does given null... and * each String ...

57. Unit testing? help.    forums.oracle.com

shawnw wrote: OK, I have tried to rap my mind around this for a few days. Unit testing. "Unit" == "one thing". You're testing each individual part of your program that can be considered a single functional unit (not necessarily a single class). Although I've heard people say "unit testing" to apply to just about everything. That works in the sense ...

58. unit testing avoid us from debugging how?    forums.oracle.com

You never avoid debugging. Unit tests help you avoid having to use a debugger and painfully stepping through your code. They do this because they can help isolate problems down to individual classes and methods. Of course, unit tests don't help in that way much if you write huge, bloated, do-everything classes that follow a poor object design. So you still ...

59. unit testing in BlueJ    forums.oracle.com

hey I can't get this to work, I get a failure when I test it. I start by creating a startTime and an endTime for an appointment, then I create the appointment, which I call "meeting" and assign the two objects to start and end. But after that I don't know how to get it right. Help public void testAddappointments() { ...

60. Unit testing    forums.oracle.com

I've started unit testing of my application using JUnit 4.0. The problem is that most of the important code is handled in private functions that can't be unit tested. What is the protocol here? I'm thinking I'll make all my methods public just for the sake of unit testing, then make them private and use the @ignore annotation in the test ...

61. Unit test for a class    forums.oracle.com

62. Unit testing a device oriented project    forums.oracle.com

I have a method that moves a stage (a hardware device) public void moveLeft(double pos) { . . . } My question is how will I unit test it ?? The only thing it does is, moving the stage depending upon the pos that is passed to it. It does not written anything. Would appreciate any kind of help on this ...

63. how to fix my code so it fits the unit test?    forums.oracle.com

yea i can tell its the constructor problem but more majorly is how? i'm like new-ish to this array thing and i would appriecate it very much if u can just provide me with a more direct solution. i tried throwing in a constructor like "int[] Math2;" or like "int [] Maths 2 = int [];" and i'm just too noob ...

64. Automatic unit testing    forums.oracle.com

I'm doing unit testing on a project and I have a test method that takes an object of any class as a parameter that I would like to run on objects from all classes in my project. This problem could easily be solved by adding a new call to the method (in some file) when I add a new class file ...

66. unit testing ......    forums.oracle.com

67. Protected methods for unit testing    forums.oracle.com

When you say you leave your tests in the same package are you leaving them in the same project? I set up a separate project for unit testing and run the tests from there. I do mirror the package structure so essentially the tests are in the same package. If you leave them in the same project any advantages to that? ...

68. information on a IllegalArgumentException in unit test    forums.oracle.com

Hi all, I have a question that probably should be in a different forum, but I am not looking for a direct solution to my problem but any information you may know. Now I am doing a tutorial from IBM regarding Spring2 and JPA. I have written a Unit Test but while Junit is loading I get the following exception. As ...

69. how to write unit testing    forums.oracle.com

Hi i have a java project. and inside it i have a class and in that i would like to perform unit testing over few methods, and these methods have void . i would like to know how to start unit testing as i am new to this. i wil place my code if required thankx

70. 1 developer writing unit tests for whole team?    forums.oracle.com

hi, i'm a java developer with 10 years programming experience. although it hasn't always been mandated on some projects i have worked on, i have always written unit tests (junit) for my own code even though most of my fellow team members didn't. i recently joined a new team. i was one of the last to join the team. so, the ...

71. Lying to unit tests about the underlying environment    forums.oracle.com

Time to restructure your class I'm not so sure. This is a utility class (called DeploymentEnvironmentDetector ) with a single, static, public method detectDeploymentEnvironment(). Behind that public method sit several private methods, one to "detect" based on environment properties, one to detect based on underling host properties (like the hostname), etc. When the public method is called, it calls each of ...

72. Unit test reviews    forums.oracle.com

Hi, I know this is more of a generic programming problem than a specific java one but I've been googling for stuff on best practices when it comes to reviewing JUnit tests. We have a J2EE web based finance application but our unit test coverage leaves a lot to be desired. Any one got any useful urls I could lookup on ...

73. Unit testing a native method    forums.oracle.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.