I am writing a test for a class which has a setup
class A
{
private String name;
public String getName()
{
return "Hello "+ name;
}
public void setName(String name)
{
this.name = name;
}
My test class
TestA
A a = new A();
{
@Before
void setup()
{
a.setName("Jack");
}
@Test
public void testTom()
{
assert(a.getString(), "Hello Tom");
}
@Test
public void testJack()
{
assert(a.getString(), "Hello Jack");
}
How to change the value of name between the methods since @Before calls for every test method? ie) if execute testJack then the output should be Hello Jack. I tried with @Parameters but before that setup is getting called so i couln't acheive this functionality.