Ability.test.ets 1.7 KB

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