Skip to content

Commit

Permalink
Merge pull request #2433 from leancodepl/fix-skipping-first-word-in-t…
Browse files Browse the repository at this point in the history
…est-name

Fix skipping first word in started TestEntry
  • Loading branch information
pdenert authored Nov 25, 2024
2 parents 0bf04f2 + daabce4 commit 641e22e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/patrol_log/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1

- Fix skipping first word in started TestEntry.

## 0.2.0

- Fix report path when path contain spaces.
Expand Down
16 changes: 13 additions & 3 deletions packages/patrol_log/lib/src/entries/test_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TestEntry extends Entry {
final TestEntryStatus status;
final String? error;

/// Returns the execution time between [start] and TestEntry [timestamp].
Duration executionTime(DateTime start) => timestamp.difference(start);

@override
Expand All @@ -28,15 +29,24 @@ class TestEntry extends Entry {
@override
String pretty() {
if (!isFinished) {
return '${status.name} $_testName';
return '${status.name} $name';
}
return '${status.name} $_testName ${AnsiCodes.gray}(integration_test/$_filePath.dart)${AnsiCodes.reset}${error != null ? '\n$error' : ''}';
return '${status.name} $nameWithPath${error != null ? '\n$error' : ''}';
}

String get nameWithPath =>
'$_testName ${AnsiCodes.gray}(integration_test/$_filePath.dart)${AnsiCodes.reset}';

/// Returns the file path of the test.
///
/// The file path is the first part of the test name.
/// '.' is replaced with '/' to create a valid file path.
String get _filePath => name.split(' ').first.replaceAll('.', '/');

/// Returns the test name without the file path.
///
/// When test is finished, then first part of the name is the file name.
/// So we skip the first part.
String get _testName => name.split(' ').skip(1).join(' ');

@override
Expand All @@ -45,7 +55,7 @@ class TestEntry extends Entry {
@override
List<Object?> get props => [name, status, error, timestamp, type];

/// Returns `true` if the test is finished successfully or with a failure.
/// Returns `true` if the test is finished, successfully or with a failure.
bool get isFinished =>
status == TestEntryStatus.success || status == TestEntryStatus.failure;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/patrol_log/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: patrol_log
description: >
Log package for Patrol, a powerful Flutter-native UI testing framework.
version: 0.2.0
version: 0.2.1
homepage: https://patrol.leancode.co
repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_log
issue_tracker: https://github.com/leancodepl/patrol/issues
Expand Down

0 comments on commit 641e22e

Please sign in to comment.