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:
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));
}}
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!