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
To run the integration tests, complete the following steps on the command line:
366
369
370
+
```azurecli
371
+
az login # Required when no service principal environment variables are present
372
+
```
373
+
367
374
```shell
368
-
$ cd [Your GoPath]/src/staticwebpage
369
-
GoPath/src/staticwebpage$ dep init # Run only once for this folder
370
-
GoPath/src/staticwebpage$ dep ensure # Required to run if you imported new packages in test cases
371
-
GoPath/src/staticwebpage$ cdtest
372
-
GoPath/src/staticwebpage/test$ go fmt
373
-
GoPath/src/staticwebpage/test$ az login # Required when no service principal environment variables are present
374
-
GoPath/src/staticwebpage/test$ go test -run TestIT_HelloWorldExample
375
+
cd [Your GoPath]/src/staticwebpage
376
+
dep init # Run only once for this folder
377
+
dep ensure # Required to run if you imported new packages in test cases
378
+
cdtest
379
+
go fmt
380
+
go test -run TestIT_HelloWorldExample
375
381
```
376
382
377
383
The traditional Go test result returns in about two minutes. You could also run both unit tests and integration tests by executing these commands:
378
384
379
385
```shell
380
-
GoPath/src/staticwebpage/test$ go fmt
381
-
GoPath/src/staticwebpage/test$ go test
386
+
go fmt
387
+
go test
382
388
```
383
389
384
390
Integration tests take much longer than unit tests (two minutes for one integration case compared to one minute for five unit cases). But it's your decision whether to use unit tests or integration tests in a scenario. Typically, we prefer to use unit tests for complex logic by using Terraform HCL functions. We usually use integration tests for the end-to-end perspective of a user.
@@ -491,13 +497,16 @@ func Clean() error {
491
497
492
498
You can use the following commands to execute a full test suite. The code is similar to the running steps we used in an earlier section.
493
499
500
+
```azurecli
501
+
az login # Required when no service principal environment variables are present
502
+
```
503
+
494
504
```shell
495
-
$ cd [Your GoPath]/src/staticwebpage
496
-
GoPath/src/staticwebpage$ dep init # Run only once for this folder
497
-
GoPath/src/staticwebpage$ dep ensure # Required to run if you imported new packages in magefile or test cases
498
-
GoPath/src/staticwebpage$ go fmt # Only required when you change the magefile
499
-
GoPath/src/staticwebpage$ az login # Required when no service principal environment variables are present
500
-
GoPath/src/staticwebpage$ mage
505
+
cd [Your GoPath]/src/staticwebpage
506
+
dep init # Run only once for this folder
507
+
dep ensure # Required to run if you imported new packages in magefile or test cases
508
+
go fmt # Only required when you change the magefile
509
+
mage
501
510
```
502
511
503
512
You can replace the last command line with additional mage steps. For example, you can use `mage unit` or `mage clean`. It's a good idea to embed `dep` commands and `az login` in the magefile. We don't show the code here.
0 commit comments