LocalUnit.test.ets 1.6 KB

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