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