JUnit test case problem.

Reply

Join Date: May 2007
Posts: 20
Reputation: Lioshenka is an unknown quantity at this point 
Solved Threads: 0
Lioshenka Lioshenka is offline Offline
Newbie Poster

JUnit test case problem.

 
0
  #1
Mar 2nd, 2008
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:
  1. import static org.junit.Assert.*;
  2. import org.junit.Test;
  3.  
  4. public class ProperPirateTest {
  5.  
  6. @Test
  7. public void testTalkMethod() {
  8. int num =1;
  9. ProperPirate tester = new ProperPirate();
  10. assertEquals("Ahoy ", tester.talk(2));
  11. }}
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!
Last edited by Lioshenka; Mar 2nd, 2008 at 11:38 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC