Skip to main content

Starting to Contribute

Testing

Unit Tests

Rust

We are using regular unit tests as by the Rust Book. You can run them with cargo test .

Note: For async unit test, we are using tokio so mark them with #[tokio:test] (rather than #[test]). Example:

use anyhow::Result;

#[tokio::test]
async fn testing_my_feature() -> Result<()> {
    // ... test code
    Ok(())
}

Flutter Widget tests

Note: We currently don't have proper widget unit tests. So this is mainly here for when we do have them available.

cd app
flutter test

Integration Tests

Infrastructure

You need a fresh synapse matrix backend with a specific configuration. We recommend to use the test-server setup we provide in util/test_server, that uses docker-compose on Linux (so you need docker and docker-compose on your linux) or puts that into a Vagrant virtual machine on all other platforms.

Vagrant Virtual Machine (on Windows & Mac)

If you are not on a Linux machine, please install vagrant and a corresponding provider (probably VirtualBox). Then simply run cargo make test-server from the repository root and it will provision the virtual machine and start the synapse matrix backend.

Alternatively you can run your own Linux Machine in a VM and use the util/test_server from there.

It is generally not recommended to run your own backend infrastructure as we have several services, plugins and other parts as requirements and we are not tracking changes to them in any other way than updating those files.

esting the server

Your server should now show the default "welcome" screen when you open the browser at http://localhost:8118 (or any external address if you changed that).

Mock data

The rust integration tests expect a certain set of mock data. You can easily get this set up by running

cargo run -p acter-cli -- mock --homeserver-url $DEFAULT_HOMESERVER_URL --homeserver-name localhost

Reset docker

To start the docker-compose afresh:

  1. stop the service with docker-compose stop
  2. remove the data at rm -rf .local
  3. start the service with docker-compose up -d

Rust integration tests

To run the rust integration tests, you need a fresh integration testing infrastructure (see above) available at $DEFAULT_HOMESERVER_URL. Assuming you are running the docker-compose setup, this would be http://localhost:8118 (which is the fallback default, so you don't have to put it into your environment). Then you can run the integration test with:

In Windows:
You can set up environment variable for cargo as following (assuming the server is accessible at 10.0.0.1:8008 and log level is info):

$env:DEFAULT_HOMESERVER_URL="http://10.0.0.1:8008"; $env:RUST_LOG="info"; cargo nextest run -p acter-test -- --nocapture

In Linux / Macos:
You can set up environment variable for cargo as following (assuming the server is available at 10.0.0.1:8008 and log level is warn):

DEFAULT_HOMESERVER_URL="http://10.0.0.1:8008" RUST_LOG="warn" cargo nextest run -p acter-test -- --nocapture

If you have the Flutter extension for vscode you can also run the Run Integration Tests (acter) launch commend from within your VSCode to run the tests directly or use the Run Local Integration Tests on the specific test from within your editor. To debug an integration tests, use the Debug Integration Tests (acter) on the specific test from within the editor - which allows you to add breakpoints and debugging widgets as usual.

Flutter UI integration tests

We are using convenient_tests framework to build and run flutter integration tests. The default test target is an Android Emulator. You need the above mentioned backend setup

Running with the Manager

You can easily run the test manager by preparing everything for the target you want to test on (e.g. start the android-emulator, build cargo make android-dev) and then start the test-server and test-manager app by running cargo make ui-tester. While leaving this open, in a second terminal start the app in ui test mode via cargo make ui-test-app (or cargo make ui-test-app-android-emulator for the android-emulator version). You can now reconnect from the manager UI and run the specific tests.