Skip to content
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

Fix skipping first word in started TestEntry #2433

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading