How to write a test case

What is a good test

  1. Small test, with only one goal.
  2. Independent test, a test does not relate to another one.
  3. Same test can be run multi-time.
  4. Every team can understand the test.

Which syntax to write a test

There is several ways to describe a test. We chose Gherkin syntax because it is a standard and it is well documented. With Gherkin a test looks like a scenario which describes a use case. These scenarios are useful for a better collaboration across all teams during the whole development of a feature.

The reference: https://cucumber.io/docs/gherkin/reference/

Scenario: Title of the test case
  Given [Setup]
  And [more context]
  When [Action]
  Then [Assertion]
  And [more outcome]

Where add a test case

The dedicated feature test case is used for this purpose. A GitLab test case is similar to an issue we can add some metadata with label. These metadata will be useful for creating future test run by theme, feature, version with our tool.

Each test case has to include:

  • GitLab test case title is equals to the Gherkin scenario title.
  • Only one Gherkin scenario with the dedicated code highlight gherkin.
  • (optional) Add technical help for the tester.

Example

Upload a file with chunk upload

Scenario: Upload a file with chunk upload
  Given a Murena account is configured
  When the user push a file greater than 3MB to "Documents"
  Then edrive detects the file
  And it uses the chunk upload
  When the user switches off the network
  Then edrive stops the upload due to network issue
  And edrive pauses the upload
  And the given file is not visible on Murena cloud
  When edrive triggers the next sync
  Then edrive continues the upload
  And the file is fully uploaded on the Murena cloud

Help

Print edrive logs:

adb logcat --pid $(adb shell pidof -s foundation.e.drive)

Push a 150MB file to the device:

adb shell dd if=/dev/zero of=/storage/self/primary/Documents/test-file.qa bs=1 count=0 seek=150MB

Download the file from Murena cloud:

curl -X GET -u 'username@e.email:PASSWORD' https://murena.io/remote.php/dav/files/username@e.email/Documents/test-file.qa --output /tmp/test-file.qa

Tests facets

The test plan of any project should take into account the following facets:

  1. mobile - tablet - desktop
  2. light mode - dark mode
  3. new user - existing user (update, backward compatibility)
  4. arm32 - arm64 - x86
  5. portrait - landscape
  6. different languages
  7. online - offline
  8. accessibility, including scrolling
  9. single user - multiple user - pro-profile
  10. Behavior after a reboot (especially for services)