leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
854 stars 127 forks source link

Bring back test suites #1501

Open jBorkowska opened 1 year ago

jBorkowska commented 1 year ago

[@bartekpacia here - I'm editing this message sometimes to keep it updated]

bartekpacia commented 1 year ago

Scope: most of the stuff from #1341

In particular:

jBorkowska commented 1 year ago

size: L

bartekpacia commented 1 year ago

Starting scope

I'd do iOS first, because I'm more uncertain what we want to do is possible there.

iOS:

Android:

Possible problems - iOS


Resources I've found:

bartekpacia commented 1 year ago

iOS - going further

I managed to start the app under test (using XCUIApplication.launch) from within PrincipalClass in its testBundleWillStart callback (from XCTestObservation, which PrincipalClass conforms to).

Next steps:

  1. Construct the XCTestCase programatically (i.e. dynamically) and run a simple tests
  2. Further investigate if XCTestSuites can contain other XCTestSuites. We need nesting. UPDATE It's likely not possible.
  3. Move the long-running gRPC server to PrincipalClass
bartekpacia commented 1 year ago

A different approach

I just had a great talk with @zltnDC and he suggested a fresh approach to the test suites problem.

  1. Improve test execution model to support nested group()s and lifecycle callbacks. This is already tracked in #1503, but currently as part of #1501.
  2. Provide a convenient way for the user to create an "enhanced report" from the "raw report" (the one we currently have). This would replace #1502.

Why?

Recreating Dart test hierarchy natively is hard

And maybe even impossible (the research above isn't done). See SO question I asked.

Let's just not do it. Patrol's user doesn't care about how the tests are executed – if they're "flat", or if they're natively grouped. What they do care about is the test report. So let's just give them the test report.

Exampe test hierarchy:

Details ``` integration_test ├── feature_bravo │   ├── 1_test.dart │   └── 2_test.dart └── feature_delta ├── 1_test.dart └── 2_test.dart ```

Below is how the report looks like currently (copied from #1341). Let's call it "raw report":

test feature_bravo.1_test.dart ✅
test feature_bravo.2_test.dart ✅
test feature_delta.1_test.dart ✅
test feature_delta.2_test.dart ✅

but we'd like in to look like this (let's call it "enhanced report"):

group feature_bravo
├── test 1_test.dart ✅
└── test 2_test.dart ✅
group feature_delta
├── test 1_test.dart ✅
└── test 2_test.dart ✅

Good news is that the "raw report" contains all information needed to create an "enhanced report" out of it. We could provide a command like patrol reconstruct to convert the .xmls and .xcresults back to the original hierarchy from Dart.

raw_report.xml --> patrol reconstruct --> enhanced_report.xml

We still have to allow for group()s and lifecycle callbacks

The patrol reconstruct described above doesn't solve this problem. But discussion about it belongs into #1503 and #1619 (https://github.com/leancodepl/patrol/issues/1619#issuecomment-1677359318).

Pros and cons