-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Dart-side group()
s and multiple test()
s
#1619
Comments
A problem with this is that the execution model of tests will change. Developers usually expect that their test file executes once, roughly from top to bottom. But when we implement the feature that this issue talks about, it'll become more complex. ExampleLet's consider a test file: void main() {
late int photoCount;
group('test that photos are downloaded', () {
test('download photos', () {
photoCount = ...;
});
test('tap on the last but one photo', () {
// do something that depends on photoCount
});
});
} The user might reasonably expect that photoCount will be set during the second test, because it's set by the previous test. But it'll not be set, because every test case would be run in a new app process. |
group()
sgroup()
s and multiple test()
s
Maybe I am not speaking for the majority here, but in the example you gave I think it would be totally reasonable for it to fail. Relying on execution order of individual tests sounds like an anti pattern to me. Test tooling seems to even support options that would break dependency on order ( |
It is, but I've seen our QAs do it quite a few times. I'm afraid that those additional restrictions will be tricky for them. |
We could also run a whole test file in a new app process, instead of running each test case in a new app process. This would maybe feel more natural? I think it'd also make the distinction between the two types of "grouping" more clear:
|
Idea: lint to not create global state ("non-local-to-test-case state") in Patrol tests. |
Also, a big consideration is I propose the following:
|
Test names should be the same on iOS and Android. Currently, native test name is: file path + groups + test case name. The problem is with encoding this in Swift/Objective-C. We can't have names like on Android: Related issue: #1486 |
Test names proposalRestrictions:
An exampleIt's a good practice to make // integration_test/examples/some_example_test.dart
group('HomeScreen', () {
group('when not signed in', () {
test('shows sign-in dialog'), () {
// ...
});
test('does something else'), () {
// ...
});
});
group('when signed in'), () {
test('shows newsletter dialog'), () {
// ..
});
test('does a nice thing'), () {
// ..
});
}); It'd result in 4 test cases:
|
Because of the restrictions this proposal it's ok but I don't like these restrictions at all. It makes it ugly and for my test cases it'll be unreadable. My example test case name: "Verify navigation from BottomNavigationBarContainer when accessory is not connected". |
We could do:
Explainer: we replace filesystem |
okay, it's better idea for me |
This will require us to prohibit using |
@bartekpacia is group() and test() feature is already available? I tried using it, but its not working the app gets stuck at login screen
|
I am also experiencing this issue when using a @bartekpacia could #1634 resolve this when released? |
Currently you cannot use |
I am using the latest versions of patrol and patrol_cli. Update: import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';
void main() {
late int number;
setUpAll(() => number = 0);
group('GroupTest', () {
patrolTest('FirstPatrol', nativeAutomation: true, ($) async {
number++;
expect(number, 1);
});
patrolTest('SecondPatrol', ($) async {
number++;
expect(number, 2);
});
group('InsideGroupTest', () {
patrolTest('FirstPatrol', ($) async {
number++;
expect(number, 3);
});
patrolTest('SecondPatrol', ($) async {
number++;
expect(number, 4);
});
});
});
} I found out by running this code that if nativeAutomation is set to true, for the next tests setUpAll will be recalled once again. |
@bartekpacia any thought on my last comment? |
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. |
A subtask of #1501.
The text was updated successfully, but these errors were encountered: