Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: java testing

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java testing

    I have a java program written and want to write at least one test for each class. What would you recommend for using to unit test java classes?

    thanks
    Last edited by java_novice; March 13th, 2012 at 09:21 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: java testing

    It really depends on what the class does. What is your actual question?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java testing

    what do you use to unit test your classes?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java testing

    I write a main() method for the class that calls its methods with many test cases.

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java testing

    Is there no automated test suites that can be run easily against Java classes to say for example, check output is correct with certain inputs?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java testing

    That sounds like a good student project. How would it work? Would the programmer that wrote the code to be tested have to define what the input could be and what the output should be?

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: java testing

    This is on the first page of google's results for searching "java automated unit testing": Welcome to JUnit.org! | JUnit.org
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    Jan 2012
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java testing

    yeah like my class takes values and does some calculations on them. Ive done something similar in c# before using nunit which has built in assert methods so I could do something like... Assert.AreEqual(4,answer), so this would check if the variable answer contained the value 4 after execution. Thanks KevinWorkman, ill look into Junit now

Similar Threads

  1. Java error correcting, testing for a square issue i think
    By djl1990 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 1st, 2011, 03:17 AM
  2. If Testing, testing for another if?
    By Rusticus in forum Loops & Control Statements
    Replies: 10
    Last Post: October 1st, 2011, 10:18 AM
  3. [SOLVED] Testing Java EE
    By serdar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 16th, 2011, 04:39 AM
  4. Testing whether a list of URLs are active or not in java?
    By aybeeryu in forum Java Networking
    Replies: 1
    Last Post: June 3rd, 2011, 09:17 AM
  5. testing Java jsp/servlets
    By cgodfrey in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: March 30th, 2011, 03:44 PM