Is it possible to compare the result / output of one JUnit test to another test in same class?
Below is the algorithm of
Public class CompareResult {
@Before
{
open driver
}
@After
{
quit driver
}
@Test
{
Connect to 1st website
Enter data and calculate value
Store the value in Variable A
}
@Test
{
Connect to 2nd website
Enter data and calculate value
Store the value in Variable B
}
@Test
{
Compare A and B
}
}
When I display the value of variable A & B in 3rd @Test, it is NULL. Can we not use variable in one @Test to another @Test in JUnit? Please advise, I am new to JUnit.
Why do they need to be two tests? If you are comparing the values, you really have one test with multiple methods and possibly multiple asserts. And if there aren’t any asserts in helper1 and helper2, this becomes even more apparent. A test without an assert is just testing it doesn’t blow up!