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: TestingGuide.md
+24-24
Original file line number
Diff line number
Diff line change
@@ -117,7 +117,7 @@ Tests may call external (eg. a host operating system) commands; please find furt
117
117
118
118
[Assertions](#assertions) and [diagnostic messages](#diagnostic-messages) are also available for your tests.
119
119
120
-
**Example**
120
+
#### Example ####
121
121
122
122
```squirrel
123
123
class MyTestCase extends ImpTestCase {
@@ -148,7 +148,7 @@ For example, `"Test1.agent.test.nut"` (a test file with test cases for agent cod
148
148
149
149
**Note** It is sufficient that only the test file is selected for the run, ie. it satisfies the test file search pattern defined during [test configuration](#test-configuration). The corresponding partner file will be added to the test session automatically.
150
150
151
-
**Example**
151
+
#### Example ####
152
152
153
153
Test file `"Test1.agent.test.nut"`:
154
154
@@ -194,7 +194,7 @@ Every test method, including *setUp()* and *tearDown()*, can be run either synch
194
194
195
195
Test methods should return an instance of the [Promise](https://github.com/electricimp/Promise) class if it needs to do some work asynchronously. The resolution of the Promise indicates that the test has been passed. The rejection of the Promise denotes a failure.
196
196
197
-
**Example**
197
+
#### Example ####
198
198
199
199
```squirrel
200
200
function testSomethingAsynchronously() {
@@ -290,7 +290,7 @@ The following assertions are available in tests:
290
290
291
291
Asserts that the condition is truthful.
292
292
293
-
**Example**
293
+
#### Example ####
294
294
295
295
```squirrel
296
296
// OK
@@ -306,7 +306,7 @@ this.assertTrue(1 == 2);
306
306
307
307
Asserts that two values are equal.
308
308
309
-
**Example**
309
+
#### Example ####
310
310
311
311
```squirrel
312
312
// OK
@@ -322,7 +322,7 @@ this.assertEqual(1, 2);
322
322
323
323
Asserts that a value is greater than some other value.
324
324
325
-
**Example**
325
+
#### Example ####
326
326
327
327
```squirrel
328
328
// OK
@@ -338,7 +338,7 @@ this.assertGreater(1, 2);
338
338
339
339
Asserts that a value is less than some other value.
340
340
341
-
**Example**
341
+
#### Example ####
342
342
343
343
```squirrel
344
344
// OK
@@ -354,7 +354,7 @@ this.assertLess(2, 2);
354
354
355
355
Asserts that a value is within a specified range of an expected value.
356
356
357
-
**Example**
357
+
#### Example ####
358
358
359
359
```squirrel
360
360
// OK
@@ -370,7 +370,7 @@ this.assertClose(10, 9, 0.5);
370
370
371
371
Performs a deep comparison of tables, arrays and classes.
Asserts that the function _func_ throws an error when it is called with the arguments _args_ and the context _ctx_. Returns an error thrown by _func_.
410
410
411
-
**Example**
411
+
#### Example ####
412
412
413
413
```squirrel
414
414
// OK, returns "abc"
@@ -432,7 +432,7 @@ There are three ways to display diagnostic messages in the console from your tes
432
432
433
433
Examples of tests output are provided in the [section on running tests](#running-tests).
434
434
435
-
### A Test Case Example ###
435
+
####A Test Case Example####
436
436
437
437
The utility file `myFile.nut` contains the following code:
438
438
@@ -533,7 +533,7 @@ The configuration settings include:
533
533
534
534
- `--timeout`, `--stop-on-fail`, `--allow-disconnect`, `--builder-cache`— Other settings, their meaning and default values are described in the [command’s spec](./CommandsManual.md#test-create).
535
535
536
-
**Example**
536
+
#### Example ####
537
537
538
538
```bash
539
539
> impt test create --dg MyTestDG --agent-file MyLibrary.agent.lib.nut
@@ -566,7 +566,7 @@ IMPT COMMAND SUCCEEDS
566
566
567
567
You may update the test configuration by calling [`impt test update`](./CommandsManual.md#test-update). The existing [test configuration file](./CommandsManual.md#test-configuration-files) will be updated with the new settings. The new `--test-file` option value(s) completely replace any existing setting.
568
568
569
-
**Example**
569
+
#### Example ####
570
570
571
571
```bash
572
572
> impt test update --timeout 60 --builder-cache true
@@ -597,7 +597,7 @@ IMPT COMMAND SUCCEEDS
597
597
598
598
You may also display the current test configuration by calling [`impt test info`](./CommandsManual.md#test-info).
599
599
600
-
**Example**
600
+
#### Example ####
601
601
602
602
```bash
603
603
> impt test info
@@ -639,7 +639,7 @@ For unauthenticated requests, the GitHub API allows you to make [up to 60 reques
639
639
- This file may be created or updated with [`impt test github`](./CommandsManual.md#test-github). You specify a GitHub username and password, and they are saved in the specified file. **Important** The credentials are stored in a plain text.
640
640
- You may have several GitHub credential files and they may be located in any place. You specify a concrete GitHub credentials file during [test configuration](#test-configuration). If the specified file exists when you [run the tests](#running-tests), the GitHub credentials are taken from it. If the specified file does not exist, the GitHub credentials are taken from the environment variables, if they are set.
641
641
642
-
**Example**
642
+
#### Example ####
643
643
644
644
```bash
645
645
> impt test github --github-config github.conf --user github_username
@@ -666,7 +666,7 @@ Every test is treated as failed if an error is thrown or a timeout, as defined i
666
666
667
667
When all tests are passed, the [`impt test run`](./CommandsManual.md#test-run) command outputs `IMPT COMMAND SUCCEEDS` and returns an exit code of zero. Otherwise, it outputs `IMPT COMMAND FAILS` and returns a non-zero exit code.
668
668
669
-
**Example: Testing Failed**
669
+
#### Example: Testing Failed ####
670
670
671
671
```bash
672
672
> impt test run
@@ -703,7 +703,7 @@ Error: Testing failed
703
703
IMPT COMMAND FAILS
704
704
```
705
705
706
-
**Example: All Tests Passed**
706
+
#### Example: All Tests Passed ####
707
707
708
708
```bash
709
709
> impt test run
@@ -749,7 +749,7 @@ The `--tests <testcase_pattern>` option of the [`impt test run`](./CommandsManua
749
749
750
750
- `testMethod` is the name of a test method. Should be fully qualified. Test methods with an identical name may exist in different test cases;in this situation all of them will be selected if the cases are selected.
751
751
752
-
**Example**
752
+
#### Example ####
753
753
754
754
A test file `TestFile1.test.nut` contains:
755
755
@@ -790,7 +790,7 @@ You may run your tests in debug mode by specifying the `--output debug` option o
790
790
- All communications with the [*impUnit*test framework](https://github.com/electricimp/impUnit) are displayed in the console.
791
791
- Device and agent code forall the running builds are placedin the `.build` folder inside the test home.
792
792
793
-
**Example**
793
+
#### Example ####
794
794
795
795
```bash
796
796
> impt test run --tests TestFile1:MyTestCase::testMe --output debug
@@ -879,7 +879,7 @@ IMPT COMMAND SUCCEEDS
879
879
880
880
After testing is complete, you may want to clean the various entities created during testing. If you want to delete your test project, call [`impt test delete`](./CommandsManual.md#test-delete) from the test home. This deletes the [test configuration file](./CommandsManual.md#test-configuration-files), the *Builder* cache directory and any debug information. By specifying additional options you may also delete the GitHub credentials file, any file containing *Builder* variables, and impCentral API entities (Device Group, Deployments, Product) which were used or created during testing. Please see the [delete command’s spec](./CommandsManual.md#test-delete) for more information.
881
881
882
-
**Example**
882
+
#### Example ####
883
883
884
884
```bash
885
885
> impt test delete --all
@@ -929,7 +929,7 @@ IMPT COMMAND SUCCEEDS
929
929
930
930
Alternatively, you may fully delete the Device Group which you used for the testing by calling `impt dg delete --dg <DEVICE_GROUP_IDENTIFIER> --builds --force`. This fully cleans all of the impCentral entities created during testing, unassigns all devices from the Device Group, deletes all builds created for the Device Group, and deletes the Device Group itself.
931
931
932
-
**Example**
932
+
#### Example ####
933
933
934
934
```bash
935
935
> impt dg delete --dg MyTestDG --builds --force
@@ -969,7 +969,7 @@ IMPT COMMAND SUCCEEDS
969
969
970
970
If you only want to unassign the devices from the testing Device Group, use [`impt dg unassign`](./CommandsManual.md#device-group-unassign) or [`impt device unassign`](./CommandsManual.md#device-unassign).
971
971
972
-
**Example**
972
+
#### Example ####
973
973
974
974
```bash
975
975
> impt dg unassign --dg MyTestDG
@@ -991,7 +991,7 @@ IMPT COMMAND SUCCEEDS
991
991
992
992
If you want to delete the Product, use [`impt product delete`](./CommandsManual.md#product-delete).
0 commit comments