File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
samples/Grpc/GrpcGreeterClient.Tests Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,12 @@ namespace GrpcGreeterClient.Tests
1515{
1616 public class GrpcGreeterClientTests : IDisposable
1717 {
18+ private readonly ITestOutputHelper output ;
1819 private readonly ISynchronousPluginPactBuilderV4 pact ;
1920
2021 public GrpcGreeterClientTests ( ITestOutputHelper output )
2122 {
23+ this . output = output ;
2224 var config = new PactConfig
2325 {
2426 PactDir = "../../../../pacts/" ,
@@ -58,6 +60,8 @@ public void ThrowsExceptionWhenNoGrpcClientRequestMade()
5860 {
5961 // No grpc call here results in failure.
6062 } ) ) ;
63+
64+ this . WriteLogs ( ) ;
6165 }
6266
6367 [ Fact ]
@@ -90,6 +94,16 @@ await this.pact.VerifyAsync(async ctx =>
9094 // Assert
9195 greeting . Should ( ) . Be ( "Hello foo" ) ;
9296 } ) ;
97+
98+ this . WriteLogs ( ) ;
99+ }
100+
101+ private void WriteLogs ( )
102+ {
103+ this . output . WriteLine ( string . Empty ) ;
104+ this . output . WriteLine ( "Pact Interaction Logs" ) ;
105+ this . output . WriteLine ( "-----------" ) ;
106+ this . output . WriteLine ( pact . FetchLogs ( ) ) ;
93107 }
94108
95109 public void Dispose ( ) => this . pact ? . Dispose ( ) ;
Original file line number Diff line number Diff line change @@ -5,4 +5,10 @@ namespace PactNet;
55public interface ISynchronousPluginPactBuilderV4 : IPactBuilder , IDisposable
66{
77 ISynchronousPluginRequestBuilderV4 UponReceiving ( string description ) ;
8+
9+ /// <summary>
10+ /// Fetch the interaction logs as a string.
11+ /// </summary>
12+ /// <returns>Logs</returns>
13+ string FetchLogs ( ) ;
814}
Original file line number Diff line number Diff line change 11using PactNet . Drivers . Plugins ;
2+ using PactNet . Interop ;
23using PactNet . Models ;
34
45namespace PactNet ;
@@ -16,5 +17,11 @@ public ISynchronousPluginRequestBuilderV4 UponReceiving(string description)
1617 return new SynchronousPluginRequestBuilder ( pact . NewSyncInteraction ( description ) ) ;
1718 }
1819
20+ /// <summary>
21+ /// Fetch the interaction logs as a string.
22+ /// </summary>
23+ /// <returns>Logs</returns>
24+ public string FetchLogs ( ) => NativeInterop . FetchLogBuffer ( null ) ;
25+
1926 public void Dispose ( ) => pact ? . Dispose ( ) ;
2027}
You can’t perform that action at this time.
0 commit comments