File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes junit - basics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "junit - basics" Watch "junit - basics" New topic
Author

junit - basics

petr pavlovich
Greenhorn

Joined: Jul 10, 2011
Posts: 22
Hello people!
All the best!
Help me understand the writing junit test.
This is my first junit test in life.
Assignment:

Methods return the 6 numbers, which are the coordinates of three vertices of a right triangle in a Cartesian coordinate system

There is a method that returns the right-angled triangle:

Requires: junit test to write code that checks the method getRtriangle that he actually returns a right triangle

My attempt to build a junit test.
//As I understood from the job myself to write the implementation getRtriangle






Do I do it?
Tell me, please.
Are there any errors?

Thank you!

Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 122
petr pavlovich wrote:Hello people!
Do I do it?
Tell me, please.
Are there any errors?


Petr,

I do not understand what your class is trying to do. What is the resault of the test? I suspect it fails as this is the last line of the junit code.

As a broad statement, I don't think the JUnit test is valid but I do not know what "valid' really is.

What does the RtriangleProvider do? It looks like it returns various points. The only thing you can test for RTriangle, per se, is that the points are returned as expected (assertEquals would be one JUnit statement to consider). I suggest RtriangleProvider implement the RTriangle interface and should also have a constructor accepting the points and that you use that constructor instead of a static getRTriangle method.

From there I am not really sure what to say. If you are trying to confirm whether or not the triangle is a right triangle, then to me it would made sense to have an "isRightTriangle" method returning a boolean or something like that coded on the interface that your class implements. Your test(s) would then be able to feed sets of data points in and the test would assert that isRightTriangle is true or false as appropriate based on the points provided.
petr pavlovich
Greenhorn

Joined: Jul 10, 2011
Posts: 22


test method for testing getRtriangle that he really returns a right triangle

Console :

please help
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 122
Petr,



Check your classpath. Based on the error, it appears the JUnit jar is not defined properly in the classpath.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: junit - basics
 
Similar Threads
whats wrong with my code ?
args.length problem
methods and return type
Triangle Problem
is rectangle?