1 package otherTests.testng;
2
3 import static org.testng.Assert.assertNotNull;
4
5 import mockit.Expectations;
6 import mockit.Mocked;
7
8 import org.testng.annotations.BeforeMethod;
9 import org.testng.annotations.Test;
10
11 public final class TestNGCascadingInSetupTest {
12 static class Foo {
13 Bar getBar() {
14 return null;
15 }
16 }
17
18 static class Bar {
19 String getValue() {
20 return null;
21 }
22 }
23
24 @Mocked
25 Foo foo;
26
27 @BeforeMethod
28 public void recordValueForCascadedInstance() {
29 new Expectations() {
30 {
31 foo.getBar().getValue();
32 result = "test";
33 }
34 };
35 }
36
37 @Test
38 public void useExpectationResultRecordedOnCascadedInstanceFromSetupMethod() {
39 String value = foo.getBar().getValue();
40
41 assertNotNull(value);
42 }
43 }