mutation-test icon indicating copy to clipboard operation
mutation-test copied to clipboard

Only run specific test

Open hschaeufler opened this issue 1 year ago • 2 comments

Is it possible to specify the test to be executed directly in the command? I would like to execute only the unit test associated with the specified code file. For Example: dart run mutation_test lib/code_file.dart -test lib/code_file_test.dart

hschaeufler avatar Oct 04 '24 11:10 hschaeufler

For those who are interested. I have found a workaround. I write the following with the widget to test in a cfg.xml:

flutter test /path/to/widget_test.dart

Than I run the test with the following command: dart run mutation_test /path/to/widget.dart --rules tmp.cfg.xml --builtin --format none

hschaeufler avatar Oct 09 '24 07:10 hschaeufler

It won't work if you want to use the mutation test in a CI environment.

If you try adding the following code to the tag in the XML file: flutter test $(echo $(git diff --name-only HEAD HEAD~1 | grep "test.dart$" | tr '\n' ' **'))**

The _addCommand method will split it by blank spaces, causing the code to malfunction:

https://github.com/domohuhn/mutation-test/blob/71052092245a28cb4dace752ac63c0736a652c4b/lib/src/configuration/configuration.dart#L303

note: the Proccess.start() method should work if you pass the files argument with double quotes, but because of the split it is not possible.

is there any workaround for this? is it possible to pass a string of files to test or specify a split pattern for commands?

BrendoKatagi avatar Dec 31 '24 20:12 BrendoKatagi