• 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

 
Greenhorn
Posts: 13
1
C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there!

I am having issues testing my file:'( would be really grateful if someone can come through <3

*****************************************************************************************************
File
*****************************************************************************************************

***************************************************************************************************
This is the file I am trying to test^
***************************************************************************************************


*****************************JUnit****************************************************************


*************************************************************************************
I am trying to print the expected and the actual output ensuring that they're equal but I am not able to print any output on the console in Junit
***************************************************************************************
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure there are no compilation errors and provide the console output you're actually getting.
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sarah Singh wrote:I am trying to print the expected and the actual output ensuring that they're equal but I am not able to print any output on the console in Junit


I don't see any hints you are using JUnit framework, nor I see any tests you wrote.

Could you please clarify what do you mean?
 
Liutauras Vilda
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But it is good you decided to write some tests, so would be much easier to refactor your code - it really seem to require that.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to print to the console when you're using JUnit is like kicking a hole in the floor of your car and trying to make it go "Fred Flintstone" style.  The point of using a tool like JUnit is to make your tests self-verifying. That is, the test code itself will report "pass" or "fail" and it should be unnecessary for a human to eyeball the results as printed out to the console.

Secondly, your code is way too complex. As mentioned earlier, that code should be refactored so that you can test small parts of it separately.
 
Fran Marzoa
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Trying to print to the console when you're using JUnit is like kicking a hole in the floor of your car and trying to make it go "Fred Flintstone" style.  The point of using a tool like JUnit is to make your tests self-verifying. That is, the test code itself will report "pass" or "fail" and it should be unnecessary for a human to eyeball the results as printed out to the console.



To be fair sometimes during the development of a test it's quite convenient to print some output to the console, just to confirm the test itself is doing what it's supposed to be doing.

Of course you could recursively write JUnit tests that tests JUnit tests, but it doesn't seem a good idea... ;)

Anyway, the OP seems to have abandoned this thread.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic