Skip to content

Commit

Permalink
PatrolJUnitRunner: implement cropping test names
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Sep 20, 2023
1 parent c184703 commit 0b76a34
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ public Object[] listDartTests() {
}
Object[] dartTestCaseNames = dartTestCaseNamesList.toArray();
Logger.INSTANCE.i(TAG + "Got Dart tests: " + Arrays.toString(dartTestCaseNames));

// We need to limit the max length of the test name, otherwise Android Test Orchestrator will crash.
// See https://github.com/leancodepl/patrol/pull/1731.
// Max length of class name + test method name is 192 characters.
// MainActivityTest (the default test class name) is 16 characters.
// runDartTest is 10 characters.
// Opening "[" and closing "]" are 2 characters.
// This gives 192 - 16 - 10 - 2 = 164 characters for the Dart test name.
for (int i = 0; i < dartTestCaseNames.length; i++) {
dartTestCaseNames[i] = dartTestCaseNames[i].toString().substring(0, 164);
}

return dartTestCaseNames;
} catch (PatrolAppServiceClientException e) {
Logger.INSTANCE.e(TAG + "Failed to list Dart tests: ", e);
Expand Down

0 comments on commit 0b76a34

Please sign in to comment.