| | |
JUnit test case problem.
![]() |
•
•
Join Date: May 2007
Posts: 20
Reputation:
Solved Threads: 0
Hello, kind sirs.
I am making a JUnit test case to test one of my classes. Short description of the tested class: it takes two integers - one of them is "minLen", which is entered by the user. After that the "main" method calls the "talk" method, which sets the random value to the integer "num" and then outputs the string, which depends on those 2 values. If needed, the talk method is repeated, and the random integer is generated again (it is declared in the talk method). What I know, is that if num=1 and minLen=2, then the output string would be "Ahoy ".
Here is my test case code:
What I am trying to do, is assign the values to num, and minLen, however i am sure I am doing it in the wrong place. I think, the problem is that the num integer is generated after the talk method is called, so I assume if I set the value of 1 to it, then it will be overwritten... Is there any way around it, or what would you suggest?
PS Sorry for the complicated description, I hope it makes sense!
I am making a JUnit test case to test one of my classes. Short description of the tested class: it takes two integers - one of them is "minLen", which is entered by the user. After that the "main" method calls the "talk" method, which sets the random value to the integer "num" and then outputs the string, which depends on those 2 values. If needed, the talk method is repeated, and the random integer is generated again (it is declared in the talk method). What I know, is that if num=1 and minLen=2, then the output string would be "Ahoy ".
Here is my test case code:
Java Syntax (Toggle Plain Text)
import static org.junit.Assert.*; import org.junit.Test; public class ProperPirateTest { @Test public void testTalkMethod() { int num =1; ProperPirate tester = new ProperPirate(); assertEquals("Ahoy ", tester.talk(2)); }}
PS Sorry for the complicated description, I hope it makes sense!
Last edited by Lioshenka; Mar 2nd, 2008 at 11:38 am.
![]() |
Similar Threads
- Java/J2EE Senior Software Engineer (Software Development Job Offers)
Other Threads in the Java Forum
- Previous Thread: Help With Java
- Next Thread: Deleting Node in a Binary Search Tree?
| Thread Tools | Search this Thread |
2dgraphics 3d @param affinetransform android api applet application arc arguments array arrays automation banking binary bluetooth byte chat chatprogramusingobjects class client code color compare component count database design detection eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image input integer interface j2me java java.xls javadesktopapplications javaprojects jni jpanel julia keytool keyword linux list loop macintosh map method methods mobile netbeans newbie object os pong problem producer program programming project projectideas read recursion reference replaysolutions rim scanner server set size sms sort sql string swing terminal threads transforms tree ui unicode validation web windows





