• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

junit test method - System.getProperty() returns same value

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Always testValueWithValue1() test method fails due to client.getValue() returns value2 and testValueWithValue2() test method executes successfully.


 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just eyeballing this, I can tell it wouldn't compile ... partly because you've capitalized the "I" in "if" and partly because you don't have a return statement for the case when value is not "value1" or "value2". How can JUnit tests pass or fail if you can't even compile the class?
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"I" in "if" is typo... and in the original code has return if the value is not "value1" or "value2".
 
Greg Charles
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so if I understand, your original code was either too complex or proprietary to post here, so you posted a simplified example? That's good, and it's exactly what we suggest in our question-asking guidelines. However, it's implied that you must test the simplified code to ensure that it still demonstrates the original problem. Not only does the code you posted not compile, but when I fixed the typo, lack of return value, and also unbalanced parentheses that I didn't spot before, then both of the JUnit tests passed. Whatever bug you were experiencing seems to have been eliminated in the simplification process.
 
reply
    Bookmark Topic Watch Topic
  • New Topic