-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#785 Add
Report.Setup<TResult>(Func<TOwner, TPageObject> function)
…
…method
- Loading branch information
1 parent
0c93dae
commit 366253f
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace Atata; | ||
|
||
/// <summary> | ||
/// Provides a set of extension methods for <see cref="Report{TOwner}"/>. | ||
/// </summary> | ||
public static class ReportExtensions | ||
{ | ||
/// <summary> | ||
/// Executes the specified function and represents it in a log as a setup section with the message like <c>"Set up "<Some>" page"</c>. | ||
/// The setup function time is not counted as a "Test body" execution time, but counted as "Setup" time. | ||
/// </summary> | ||
/// <typeparam name="TOwner">The type of the owner.</typeparam> | ||
/// <typeparam name="TPageObject">The type of the result page object.</typeparam> | ||
/// <param name="report">The <see cref="Report{TOwner}"/> object.</param> | ||
/// <param name="function">The setup function.</param> | ||
/// <returns>The result page object of the <paramref name="function"/>.</returns> | ||
public static TPageObject Setup<TOwner, TPageObject>(this Report<TOwner> report, Func<TOwner, TPageObject> function) | ||
where TPageObject : PageObject<TPageObject> | ||
{ | ||
string componentFullName = UIComponentResolver.ResolvePageObjectFullName<TPageObject>(); | ||
|
||
return report.Setup($"Set up {componentFullName}", function); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Atata.IntegrationTests; | ||
|
||
public class ReportExtensionsTests : UITestFixture | ||
{ | ||
[Test] | ||
public void Setup() | ||
{ | ||
AtataContext.Current.Report.Setup(x => x | ||
.Go.To<OrdinaryPage>()); | ||
|
||
VerifyLastLogMessagesMatch( | ||
minLogLevel: LogLevel.Trace, | ||
"^> Set up \"<ordinary>\" page$", | ||
"^> Go to \"<ordinary>\" page", | ||
"^> Navigate to URL", | ||
"^< Navigate to URL", | ||
"^< Go to \"<ordinary>\" page", | ||
"^< Set up \"<ordinary>\" page"); | ||
} | ||
} |