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 3 of 3

Thread: BlueJ, Unit testing question

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Location
    Chandler, Arizona, USA
    Posts
    25
    My Mood
    Devilish
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default BlueJ, Unit testing question

    Do most unit testers use BlueJ? I am wondering what I should learn for unit testing. Also, given that you should unit test all classes, if you are writing a class that produces a ListArray of random numbers, how in the heck to you test that?


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,629
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: BlueJ, Unit testing question

    I use Eclipse, but the IDE shouldn't matter. If you are comfortable with BlueJ, use it.
    Mocking is an important and extremely powerful thing to learn when unit testing (google the Mockito api).
    You should unit test based only on the exact expected behavior of a method. Testing whether the numbers in an array or list are random is impossible (as far as I know), since you have no "expected case" to assert with. However, if the list or array the method produces should be a certain length, you could test that. Or, you could test that all the numbers in the list or array are not the same. While this probably could happen with a random generator 0.0000000000000001% of the time, it is safe to assume all the numbers should not be the same.
    Methods like the one you described are difficult to build a test case around.

    EDIT: You could also run the method twice and compare the two results. If the method truly is generating a new random list every time, the values in the two lists should not be the same.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. The Following 2 Users Say Thank You to aussiemcgr For This Useful Post:

    Jeff_Farkas (November 11th, 2013), Skywola (November 11th, 2013)

  4. #3
    Junior Member
    Join Date
    Oct 2013
    Location
    Chandler, Arizona, USA
    Posts
    25
    My Mood
    Devilish
    Thanks
    10
    Thanked 2 Times in 2 Posts

    Default Re: BlueJ, Unit testing question

    Thanks for the response . . . I use Eclipse for writing the code, but BlueJ for testing. BlueJ seems to be kind of cool because you can do UML in it too.

Similar Threads

  1. Should we be suggesting Unit Testing?
    By aussiemcgr in forum Forum Updates & Feedback
    Replies: 5
    Last Post: October 8th, 2013, 09:40 AM
  2. Java Unit Testing How-To Gettin' started
    By Massaslayer in forum Java Theory & Questions
    Replies: 2
    Last Post: May 1st, 2012, 07:58 AM
  3. Java automated testing tools for Unit testing
    By rameezraja in forum Member Introductions
    Replies: 2
    Last Post: April 14th, 2012, 08:51 AM
  4. Help in programming question. Bluej complier
    By Rads23 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: August 3rd, 2011, 09:12 PM