Skip to content

Commit c0ee834

Browse files
committed
Enhance test workflow and add file existence check in integration tests
1 parent 88bc8d0 commit c0ee834

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
run: dotnet build --configuration Release --no-restore
3737

3838
- name: "Run tests"
39-
run: dotnet test --configuration Release --no-build --verbosity normal
39+
run: dotnet test --configuration Release --no-build --logger "console;verbosity=detailed"

tests/Demo.Tests/Config/IntegrationTestsFactory.cs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class IntegrationTestsFactory : IAsyncLifetime
1515
private readonly IContainer _azureSqlEdgeContainer;
1616
private readonly IContainer _serviceBusContainer;
1717

18+
19+
1820
public IntegrationTestsFactory()
1921
{
2022
_containersNetwork = new NetworkBuilder()
@@ -32,6 +34,7 @@ public IntegrationTestsFactory()
3234
.WithNetworkAliases(sqlContainerName)
3335
.WithWaitStrategy(Wait.ForUnixContainer()
3436
.UntilMessageIsLogged("SQL Server is now ready for client connections.", w => w.WithTimeout(TimeSpan.FromSeconds(10))))
37+
.WithOutputConsumer(Consume.DoNotConsumeStdoutAndStderr())
3538
.Build();
3639

3740
_serviceBusContainer = new ContainerBuilder()
@@ -46,6 +49,7 @@ public IntegrationTestsFactory()
4649
.WithNetwork(_containersNetwork)
4750
.WithWaitStrategy(Wait.ForUnixContainer()
4851
.UntilMessageIsLogged("Emulator Service is Successfully Up!", w => w.WithTimeout(TimeSpan.FromSeconds(30))))
52+
.WithOutputConsumer(Consume.DoNotConsumeStdoutAndStderr())
4953
.Build();
5054
}
5155

tests/Demo.Tests/Tests.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
using System;
2+
using System.IO;
23
using System.Threading.Tasks;
34
using Azure.Messaging.ServiceBus;
45
using Demo.Tests.Config;
6+
using Xunit.Abstractions;
57

68
namespace Demo.Tests;
79

810
[Collection(nameof(CollectionIntegrationTests))]
9-
public class Tests(IntegrationTestsFactory factory)
11+
public class Tests(
12+
IntegrationTestsFactory factory,
13+
ITestOutputHelper output)
1014
{
1115
private readonly IntegrationTestsFactory _factory = factory;
16+
private readonly ITestOutputHelper _output = output;
1217

1318
[Fact]
14-
public async Task Test()
19+
public async Task Demo_test()
1520
{
1621
// Arrange
1722
var queueName = "demo-queue";
@@ -32,4 +37,16 @@ public async Task Test()
3237
// Assert
3338
Assert.Equal(message, messageReceived);
3439
}
40+
41+
[Fact]
42+
public void Is_file_Exists()
43+
{
44+
// Arrange && Act
45+
var path = Path.GetFullPath("./Config/ServiceBusEmulator.Config.json");
46+
47+
48+
// Assert
49+
_output.WriteLine($"Path: {path} -> Exists: {File.Exists(path)}");
50+
Assert.True(File.Exists(path));
51+
}
3552
}

0 commit comments

Comments
 (0)