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