File tree Expand file tree Collapse file tree 4 files changed +48
-3
lines changed Expand file tree Collapse file tree 4 files changed +48
-3
lines changed Original file line number Diff line number Diff line change
1
+ using NUnit . Framework . Interfaces ;
2
+ using SeleniumTests . lib . helpers ;
3
+
4
+ namespace SeleniumTests . lib . Base ;
5
+
6
+ public abstract class BaseTestWithLogging
7
+ {
8
+ [ TearDown ]
9
+ public void TrackTestResult ( )
10
+ {
11
+ var testName = TestContext . CurrentContext . Test . Name ;
12
+ var passed = TestContext . CurrentContext . Result . Outcome . Status == TestStatus . Passed ;
13
+ TestResultLogger . Log ( testName , passed ) ;
14
+ }
15
+
16
+ [ OneTimeTearDown ]
17
+ public void FinalSummary ( )
18
+ {
19
+ TestResultLogger . PrintSummary ( ) ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ using System . Collections . Concurrent ;
2
+
3
+ namespace SeleniumTests . lib . helpers ;
4
+
5
+ public static class TestResultLogger
6
+ {
7
+ private static readonly ConcurrentBag < ( string Name , string Status ) > _results = new ( ) ;
8
+
9
+ public static void Log ( string testName , bool passed )
10
+ {
11
+ var status = passed ? "\x1b [32m✅ PASSED\x1b [0m" : "\x1b [31m❌ FAILED\x1b [0m" ;
12
+ _results . Add ( ( testName , status ) ) ;
13
+ }
14
+
15
+ public static void PrintSummary ( )
16
+ {
17
+ Console . WriteLine ( "\n 📊 Test Summary:" ) ;
18
+ Console . WriteLine ( new string ( '-' , 50 ) ) ;
19
+ foreach ( var ( name , status ) in _results )
20
+ {
21
+ Console . WriteLine ( $ "{ status , - 15 } | { name } ") ;
22
+ }
23
+ Console . WriteLine ( new string ( '-' , 50 ) ) ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change 1
- using NUnit . Framework ;
2
1
using SeleniumTests . lib . Base ;
3
2
using SeleniumTests . lib . config ;
4
3
using SeleniumTests . lib . pages ;
Original file line number Diff line number Diff line change 1
- using NUnit . Framework ;
1
+ using SeleniumTests . lib . Base ;
2
2
using SeleniumTests . lib . helpers ;
3
3
4
4
namespace SeleniumTests . tests . fixtures ;
5
5
6
- public class BookStoreFixture
6
+ public class BookStoreFixture : BaseTestWithLogging
7
7
{
8
8
protected BookStoreClient Client = null ! ;
9
9
You can’t perform that action at this time.
0 commit comments