• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
3import hilog from '@ohos.hilog';
4
5export default function abilityTest() {
6  describe('ActsAbilityTest', () => {
7    // Defines a test suite. Two parameters are supported: test suite name and test suite function.
8    beforeAll(() => {
9      // Presets an action, which is performed only once before all test cases of the test suite start.
10      // This API supports only one parameter: preset action function.
11    })
12    beforeEach(() => {
13      // Presets an action, which is performed before each unit test case starts.
14      // The number of execution times is the same as the number of test cases defined by **it**.
15      // This API supports only one parameter: preset action function.
16    })
17    afterEach(() => {
18      // Presets a clear action, which is performed after each unit test case ends.
19      // The number of execution times is the same as the number of test cases defined by **it**.
20      // This API supports only one parameter: clear action function.
21    })
22    afterAll(() => {
23      // Presets a clear action, which is performed after all test cases of the test suite end.
24      // This API supports only one parameter: clear action function.
25    })
26    it('assertContain', 0, () => {
27      // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
28      hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
29      let a = 'abc';
30      let b = 'b';
31      // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
32      expect(a).assertContain(b);
33      expect(a).assertEqual(a);
34    })
35  })
36}