public class ClassOne {
private String exampleString;
public String getExampleString(){
return this.exampleString;
}
public void setExampleString(String exampleString){
this.exampleString;
}
}
public class ClassOneTest {
ClassOne classOne = new ClassOne();
@Test
void getExampleStringTest(){
classOne.setExampleString("test");
assertEquals("test", classOne.getExampleString());
}
@Test
void setExampleStringTest(){
ClassOne classOneMock = mock(ClassOneMock.class);
ClassOneMock.setExampleString("test");
verify(classOneMock, times(1));
}
I have two methods, one which sets a variable and another which gets the value of that variable. I want to be able to test by mocking the set method and verifying that the value of the variable set is correct.
I tried using ArgumentCaptor, but I'm not sure if I understand it enough to use it.