You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: system-stubs-testng/README.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,13 +34,13 @@ public void afterTest() throws Exception {
34
34
```
35
35
36
36
With this code, we'd expect tests to be able to modify the runtime environment by manipulating the
37
-
`environmentVariables` object, and we'd expect the tests to have an environment variable `setinbefore` set
38
-
to `yes`.
37
+
`environmentVariables` object, and we'd expect the tests to see the environment variables set in the `beforeTest`
38
+
function; in this example, `setinbefore` was set to `yes`.
39
39
40
-
Similarly, we can use `setup` and `teardown` inside a test case, or use the `SystemStubs` methods such as
40
+
Similarly, we can use `setup` and `teardown`methods of a `TestResources` such as `EnvironmentVariables`inside a test case, or use the `SystemStubs` wrapper methods such as
41
41
`withEnvironmentVariables`. See the [main documentation](../README.md) for more on the execute around pattern.
42
42
43
-
### Using of the Plugin
43
+
### Using the Plugin
44
44
45
45
The plugin:
46
46
@@ -54,6 +54,8 @@ Usage:
54
54
@Listeners(SystemStubsListener.class)
55
55
publicclassCaptureSystemOutTest {
56
56
57
+
// We can ininitialise this object with `new` here, or
58
+
// leave it uninitialized for the plugin to do it for us
57
59
@SystemStub
58
60
privateSystemOut out;
59
61
@@ -74,13 +76,15 @@ public class CaptureSystemOutTest {
74
76
75
77
> Note: in this instance we've used the `SystemOut` stub. We've had to remember to call its `clear` method as it
76
78
> will be shared between tests.
79
+
> Note: we may prefer to initialize our stub objects to give them configuration or initial values without using
80
+
> a `@BeforeTest` function.
77
81
78
-
We can use each of the stubs such as:
82
+
We can use any of the core system stubs classes such as:
79
83
80
84
-`EnvironmentVariables` - for overriding the environment variables
81
85
-`SystemProperties` - for temporarily overwriting system properties and then restoring them afterwards
0 commit comments