Skip to content

Commit 38510aa

Browse files
committed
Reduce CI output verbosity
- Add TestWebApplicationFactory that suppresses info/debug logs during tests, eliminating hundreds of noisy application log lines - Use minimal verbosity for dotnet test logger - Add --quiet flag to Gradle build/test/lint/ci tasks - Update all integration test classes to use TestWebApplicationFactory
1 parent 823ebd7 commit 38510aa

7 files changed

Lines changed: 31 additions & 14 deletions

File tree

quotes-analytics/.mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ run = "dotnet build quotes-analytics.sln"
1111

1212
[tasks.test]
1313
description = "Run all tests"
14-
run = "dotnet test quotes-analytics.sln --logger 'console;verbosity=normal'"
14+
run = "dotnet test quotes-analytics.sln --logger 'console;verbosity=minimal'"
1515

1616
[tasks."test:unit"]
1717
description = "Run unit tests only"

quotes-analytics/Tests/AnalyticsControllerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Nais.QuotesAnalytics.Tests;
1111

12-
public class AnalyticsControllerTests : IClassFixture<WebApplicationFactory<Program>>
12+
public class AnalyticsControllerTests : IClassFixture<TestWebApplicationFactory>
1313
{
1414
private readonly WebApplicationFactory<Program> _factory;
1515

@@ -19,7 +19,7 @@ public class AnalyticsControllerTests : IClassFixture<WebApplicationFactory<Prog
1919
new { Id = "2", Text = "Kubernetes is complex but Nais makes it simple", Author = "Platform Engineer" },
2020
});
2121

22-
public AnalyticsControllerTests(WebApplicationFactory<Program> factory)
22+
public AnalyticsControllerTests(TestWebApplicationFactory factory)
2323
{
2424
_factory = factory.WithWebHostBuilder(builder =>
2525
{

quotes-analytics/Tests/HealthEndpointTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
namespace Nais.QuotesAnalytics.Tests;
77

8-
public class HealthEndpointTests : IClassFixture<WebApplicationFactory<Program>>
8+
public class HealthEndpointTests : IClassFixture<TestWebApplicationFactory>
99
{
10-
private readonly WebApplicationFactory<Program> _factory;
10+
private readonly TestWebApplicationFactory _factory;
1111

12-
public HealthEndpointTests(WebApplicationFactory<Program> factory)
12+
public HealthEndpointTests(TestWebApplicationFactory factory)
1313
{
1414
_factory = factory;
1515
}

quotes-analytics/Tests/IntegrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Nais.QuotesAnalytics.Tests;
66

77
[Trait("Category", "Integration")]
8-
public class IntegrationTests : IClassFixture<WebApplicationFactory<Program>>
8+
public class IntegrationTests : IClassFixture<TestWebApplicationFactory>
99
{
1010
private readonly HttpClient _client;
1111

12-
public IntegrationTests(WebApplicationFactory<Program> factory)
12+
public IntegrationTests(TestWebApplicationFactory factory)
1313
{
1414
_client = factory.CreateClient();
1515
}

quotes-analytics/Tests/RoutesIntegrationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace Nais.QuotesAnalytics.Tests;
88

99
[Collection("Integration")]
10-
public class RoutesIntegrationTests : IClassFixture<WebApplicationFactory<Program>>
10+
public class RoutesIntegrationTests : IClassFixture<TestWebApplicationFactory>
1111
{
12-
private readonly WebApplicationFactory<Program> _factory;
12+
private readonly TestWebApplicationFactory _factory;
1313
private readonly HttpClient _client;
1414

15-
public RoutesIntegrationTests(WebApplicationFactory<Program> factory)
15+
public RoutesIntegrationTests(TestWebApplicationFactory factory)
1616
{
1717
_factory = factory;
1818
_client = _factory.CreateClient();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.AspNetCore.Mvc.Testing;
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace Nais.QuotesAnalytics.Tests;
6+
7+
public class TestWebApplicationFactory : WebApplicationFactory<Program>
8+
{
9+
protected override void ConfigureWebHost(IWebHostBuilder builder)
10+
{
11+
builder.ConfigureLogging(logging =>
12+
{
13+
logging.ClearProviders();
14+
logging.SetMinimumLevel(LogLevel.Warning);
15+
});
16+
}
17+
}

quotes-backend/.mise.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ run = "gradle run --continuous"
1818

1919
[tasks.build]
2020
description = "Build the Kotlin application"
21-
run = "gradle build"
21+
run = "gradle build --quiet"
2222

2323
[tasks.test]
2424
description = "Run all tests"
25-
run = "gradle test"
25+
run = "gradle test --quiet"
2626

2727
[tasks.run]
2828
description = "Run the application"
@@ -70,7 +70,7 @@ run = "semgrep scan --config p/kotlin --config p/owasp-top-ten --error ."
7070

7171
[tasks.ci]
7272
description = "Run all CI checks"
73-
run = ["gradle clean", "gradle check", "gradle build", "mise run security-scan"]
73+
run = ["gradle clean --quiet", "gradle check --quiet", "gradle build --quiet", "mise run security-scan"]
7474

7575
[tasks."dependencies:check"]
7676
description = "Check for outdated dependencies"

0 commit comments

Comments
 (0)