• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to write Junit test when a method returns multiple values

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

How to test a program that returns multiple values from a single method
How can i test getMethods() here ??

 
author & internet detective
Posts: 41093
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ravi,
First of all, that method returns one object - a List. Methods can't return multiple values.

What are you trying to test? The size of the list? The content of the list? You can have multiple assertions in a test so you can test as many things about the return value as you want.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well thank you . I want to test the contents of the List .Is that possible.
 
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course it's possible. Naturally you're going to need something more specific than just "test the contents of the List", but no doubt you actually do have something more specific, you just didn't post it, right?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right . I have posted this question because my requirement is similar to testing the contents of the List .

I can't post the code right now because its at my work place , but please tell me how to test the contents of List at once , Means i dont want



 
Jeanne Boyarsky
author & internet detective
Posts: 41093
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could write a custom assertion that checks the size of a list and then loops through a list to see if it is equivalent. Nobody here is going to write the code for you - try writing something and posting it here. Then we can give comments.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:You could write a custom assertion that checks the size of a list and then loops through a list to see if it is equivalent. Nobody here is going to write the code for you - try writing something and posting it here. Then we can give comments.




thanks
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi Kiran V wrote: please tell me how to test the contents of List at once , Means i dont want


I'm not sure what you're asking for. How will you test the contents of the list without... testing the contents of the list? If you're looking for a more generic way to test the contents of the list, then refactor out a method that does the comparison (or create your own assertion as already suggested, which might be a good idea if you're doing it a lot).
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic