Skip to content

Commit

Permalink
PAINTROID-757: Research flutter integration_test packages vs flutter …
Browse files Browse the repository at this point in the history
…test + drive (#91)
  • Loading branch information
Lenkomotive authored Jul 4, 2024
1 parent b0984c2 commit 1d2f9ec
Show file tree
Hide file tree
Showing 9 changed files with 854 additions and 794 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ jobs:
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup
run: make get

Expand All @@ -34,11 +28,7 @@ jobs:
run: make widget

- name: Integration Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
profile: Nexus 6
script: make integration
run: make integration

- name: Install xmlstarlet
run: sudo apt-get install -y xmlstarlet
Expand Down
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ FVM_PRESENT := $(shell command -v fvm 2> /dev/null)
FLUTTER_CMD := $(if $(FVM_PRESENT),fvm flutter,flutter)
DART_CMD := $(if $(FVM_PRESENT),fvm dart,dart)

INTEGRATION_TEST_DIR=test/integration
DRIVER_FILE=$(INTEGRATION_TEST_DIR)/driver/driver.dart
DART_DEFINE_ARGS=

ifdef id
DART_DEFINE_ARGS += --dart-define=id=$(id)
endif

clean:
$(FLUTTER_CMD) clean
Expand Down Expand Up @@ -38,21 +44,23 @@ unit:
widget:
$(FLUTTER_CMD) test test/widget

target ?= all
integration:
@if [ "$(target)" = "all" ]; then \
find integration_test -type f -name '*_test.dart' -print0 | xargs -0 -n1 -I {} flutter test {}; \
else \
FILE_PATH=$$(find integration_test -type f -name "$(target).dart"); \
if [ -z "$$FILE_PATH" ]; then \
echo "Test file $(target) not found."; \
exit 1; \
else \
flutter test $$FILE_PATH; \
fi \
fi

test: unit widget integration
ifeq ($(strip $(target)),)
$(FLUTTER_CMD) test $(INTEGRATION_TEST_DIR)
else
$(FLUTTER_CMD) test $(INTEGRATION_TEST_DIR)/$(target)_test.dart $(DART_DEFINE_ARGS)
endif

integration-drive:
ifeq ($(strip $(target)),)
find $(INTEGRATION_TEST_DIR) -name '*_test.dart' | while read test_file; do \
flutter drive --driver=$(DRIVER_FILE) --target=$$test_file $(DART_DEFINE_ARGS); \
done
else
flutter drive --driver=$(DRIVER_FILE) --target=$(INTEGRATION_TEST_DIR)/$(target)_test.dart $(DART_DEFINE_ARGS)
endif

test: $(FLUTTER_CMD) test

fvm_check:
@echo Using $(FLUTTER_CMD) and $(DART_CMD) based on availability of FVM
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,27 @@ Alternatively `make all` can be used to:
- all: `make test`
- unit: `make unit`
- widget: `make widget`
- integration: `make integration`

**For integration tests:**

Run the integration tests **without device**:

1. Run `make integration` to run all integration tests
2. Run `make integration target=name_test` to run a specific integration test file
example: `make integration target=line_tool`
3. Run `make integration target=name_test id=n` to run a specific test in a file
example: `make integration target=line_tool id=1`
(make sure to add the `test` suffix to the test file name)

Run the integration tests **with device**:

1. Make sure you have an iOS/Android device online by running `flutter devices`
2. Run `make integration` to run all integration tests
Run `make integration target=name_test` to run a specific integration test file
2. Run `make integration-drive` to run all integration tests
3. Run `make integration-drive target=name_test` to run a specific integration test file
example: `make integration-drive target=line_tool`
4. Run `make integration-drive target=name_test id=x` to run a specific test in a file
example: `make integration-drive target=line_tool id=1`
(make sure to add the `test` suffix to the file name)

## Issues
Expand Down
91 changes: 0 additions & 91 deletions integration_test/command_manager_test.dart

This file was deleted.

Loading

0 comments on commit 1d2f9ec

Please sign in to comment.