Skip to content

Commit ee75aa7

Browse files
committed
Merge pull request #258 from Azure/clu
Clu
2 parents 5b9c85f + a76371b commit ee75aa7

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

clu-getstart.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,53 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, you should se
8888
Testing will consist of scenario tests and unit tests. Scenario tests should be written in a form of an example and be available in `.ps1` and `.sh` formats.
8989

9090
#### Scenario Tests
91-
- Scenario tests should be saved under `./examples` directory and grouped by the package or service area. Each scenario tests should consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.
92-
93-
##### Bash Tests
91+
- Scenario tests should be saved under `./examples` directory with one directory per package. Each scenario tests should (eventually) consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.
92+
93+
##### XUnit Automation For Bash Scenario Tests
94+
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.
95+
96+
- To implement an xunit bash scenario test you must
97+
- Add a ```[Collection("SampleCollection")]``` attribute to your test class
98+
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it
99+
```C#
100+
[Collection("SampleCollection")]
101+
public class SampleTestClass
102+
{
103+
ScenarioTestFixture _fixture;
104+
public SampleTestClass(ScenarioTestFixture fixture)
105+
{
106+
_fixture = fixture;
107+
}
108+
```
109+
- Use the fixture in your test method to create a script runner for your directory and to run your test script:
110+
```C#
111+
[Fact]
112+
public void RunSampleTest()
113+
{
114+
_fixture.GetRunner("resource-management").RunScript("01-ResourceGroups");
115+
}
116+
```
117+
- Set the environment variable 'TestCredentials' to a connection string providing the credentials to use during test execution. Possible fields include:
118+
119+
| Field | Description |
120+
| ------------- |:-------------|
121+
| Username | an OrgId user name |
122+
| ServicePrincipal | a service principal name |
123+
| Password | the password or application secret to sue for authentication |
124+
| TenantId | (required for Service authentication) The tenant guid to authenticate against |
125+
| SubscriptionID | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
126+
- The infrastructure automatically generates a resource group name and assigns the value to the bash variable ```"$resourceGroupName"```. If your scripts require additional variables, you can add these to your environment before running tests, or you can generate values using the ScriptRunner (for the tests using that runner).
127+
```C#
128+
runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
129+
```
130+
- Tests can be executed in vs, or by runnign ```dnx test project.json```. If you execute dnx test from the project directory, it will work without modification and a log file for each script will be written to the test results directory ```..\TestResults```. If you execute dnx test from a different directory, you must set the following environment variables to provide the path to the examples directory and where to write log files:
131+
132+
| Environment Variable | Description |
133+
| ------------- |:-------------|
134+
| ExamplesDirectory | The path to the 'examples' directory ($pshome/examples) |
135+
| TestDirectory | The path to the directory where logs will be written |
136+
137+
##### Running Bash Tests using Bash shell
94138
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
95139
- To manually run the tests; please set the following envt. variables for authentication and run `./examples/lib/testrunner.sh`
96140
```bash

0 commit comments

Comments
 (0)