-
Junit tests for toString()
I want to create a toString test but i have alot of descriptive text inside my string and two strings will never be the same as shown below:
public String toString(){
return ("Name: " + fname + ", " + lname + "Product: " + product);
}
aCustomer.toString("Andrew", "Bogart", "Coke");
It will not be the sane as name and product are not included.
I am currently printing out the toString extracted from customer class and using println to show the expected result as shown below
System.out.println("Expected " + "Name :" + "Andrew" + ", " + "Boggart" + " Product: " + Coke);
System.out.println(aCustomer.toString("Andrew", "Bogart", "Coke"));
Does anyone have a better way to test the toString method using Junit tests?
-
Pattern matching is usually a viable alternative, if the version of java that you are using supports it. Check out the Regular Expression tutorial at: http://java.sun.com/docs/books/tutorial/extra/regex/
Hope this helps.
~evlich
Similar Threads
-
By yogeshseth in forum Java
Replies: 0
Last Post: 07-19-2005, 05:01 AM
-
By yogeshseth in forum Java
Replies: 0
Last Post: 07-06-2005, 05:06 AM
-
Replies: 2
Last Post: 06-11-2003, 10:25 AM
-
Replies: 2
Last Post: 02-03-2003, 10:56 AM
-
By Scott Brookhart in forum Java
Replies: 1
Last Post: 11-07-2000, 04:08 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|