Running automated tests
Codemagic supports running unit, integration and widget tests as well as static code analysis with flutter analyze. When testing is enabled, tests are run automatically every time your project is built. You can configure the test settings in App settings > Test.
During the first build of your app, Codemagic will scan the content of the repository and automatically detect the tests according to the project structure. The expected locations of the tests are as follows:
Unit and widget tests:
Integration tests (Flutter Driver tests):
Specifying the test target
In App settings > Test, you will see the Flutter test target and Flutter drive target fields displayed if the respective tests are detected. You can specify the exact target to run a specific test.
Running Flutter Driver tests
There are several options for running integration tests during the build. You can select one option per workflow:
- iOS simulator (selected by default)
- Android emulator
- AWS Device Farm — enables to run tests on physical Android and iOS devices. Requires an AWS account and additional setup.
Stop build if tests fail
Selecting the Stop build if tests fail option will stop the build immediately when any of the tests fail. As the tests are run before building the app for selected platforms, you can get the result of the build faster. Such builds will have the status “failed”.