Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.3 KB

README.md

File metadata and controls

39 lines (27 loc) · 1.3 KB

Testing guidelines

Important! All test files must end with _test.dart to be caught by the flutter test commandline tool.

Conventions

  • A test description must conform to the GIVEN, WHEN, THEN syntax. Example: GIVEN no token in SecureStorage WHEN calling onRequest THEN no Authorization Header is added to the request.
  • A test should be limited to only test one case

Mocking

The Mockito package is used for mocking classes in unit tests.

A class which should be mocked, is declared in the @GenerateMocks([Type]) annotation. Then a Mock of the class is generated by code generation.

// Annotation which generates the secure_storage.mocks.dart library and the MockSecureStorage class.
@GenerateMocks([SecureStorage])
void main() {
  // Create mock object.
  var cat = MockSecureStorage();
}

Golden tests

Golden files for UI tests are auto-generated. This is doing by first implementing the test (Pump widget, compare to golden file), then generating the file using

  flutter test --update-goldens [path/to/test.dart]

If no path is given, all goldens will be updated.

Due to OS specific rendering, golden tests will fail in the pipeline if not generated using a linux distro.

(TODO: Make dockerfile for golden generation)