Skip to content

Commit ec972cd

Browse files
committed
merged tests
2 parents be50737 + e3d90e5 commit ec972cd

11 files changed

+35
-102
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Build .NET Library
22

33
on:
4-
push:
5-
branches: [ develop ]
64
pull_request:
75
branches: [ develop, main ]
86
release:
@@ -29,7 +27,7 @@ jobs:
2927
- name: Install dependencies
3028
run: dotnet restore
3129
- name: Build
32-
run: dotnet build --configuration Release --no-restore
30+
run: dotnet build --configuration Release
3331
- name: Test
3432
run: dotnet test --no-restore --verbosity normal
3533
- name: Upload a Build Artifact

.github/workflows/sonarqube-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
sonarOrganization: qatoolkit
2929
dotnetBuildArguments: ./src/QAToolKit.Engine.Bombardier/QAToolKit.Engine.Bombardier.csproj
3030
dotnetTestArguments: ./src/QAToolKit.Engine.Bombardier.Test/QAToolKit.Engine.Bombardier.Test.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
31-
sonarBeginArguments: /d:sonar.verbose="true" /d:sonar.language="cs" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests.cs"
31+
sonarBeginArguments: /d:sonar.verbose="true" /d:sonar.language="cs" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml"
3232
sonarHostname: "https://sonarcloud.io"
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.3.1</Version>
3+
<Version>0.3.2</Version>
44
</PropertyGroup>
55
</Project>

src/QAToolKit.Engine.Bombardier.Test/BombardierTestsGeneratorTests.cs

Lines changed: 14 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.Extensions.Logging;
22
using Newtonsoft.Json;
33
using QAToolKit.Core.Models;
4-
using QAToolKit.Core.Test;
54
using QAToolKit.Engine.Bombardier.Exceptions;
65
using System;
76
using System.Collections.Generic;
@@ -554,7 +553,7 @@ public async Task GenerateBombardierTestGetSupportNoIdTest_Successfull()
554553
}
555554

556555
[Fact]
557-
public async Task GenerateBombardierTestGetBikesInsecureTest_Successfull()
556+
public async Task GenerateBombardierTestGetAllBikesInsecureTest_Successfull()
558557
{
559558
var content = File.ReadAllText("Assets/GetAllBikes.json");
560559
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
@@ -576,7 +575,7 @@ public async Task GenerateBombardierTestGetBikesInsecureTest_Successfull()
576575
}
577576

578577
[Fact]
579-
public async Task GenerateBombardierTestAddBikeInsecureTest_Successfull()
578+
public async Task GenerateBombardierTestAddNewBikeInsecureTest_Successfull()
580579
{
581580
var content = File.ReadAllText("Assets/AddBike.json");
582581
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
@@ -598,7 +597,7 @@ public async Task GenerateBombardierTestAddBikeInsecureTest_Successfull()
598597
}
599598

600599
[Fact]
601-
public async Task GenerateBombardierTestDoesNotEndWithNewLineTest1_Successfull()
600+
public async Task GenerateBombardierTestDoesNotEndWithNewLineTest_Successfull()
602601
{
603602
var content = File.ReadAllText("Assets/AddBike.json");
604603
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
@@ -623,7 +622,7 @@ public async Task GenerateBombardierTestDoesNotEndWithNewLineTest1_Successfull()
623622
}
624623

625624
[Fact]
626-
public async Task GenerateBombardierTestDoesNotEndWithNewLineTest2_Successfull()
625+
public async Task GenerateBombardierTestDoesNotEndWithNewLineTestAlternative_Successfull()
627626
{
628627
var content = File.ReadAllText("Assets/AddBike.json");
629628
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
@@ -770,93 +769,29 @@ public async Task GenerateBombardierTestRateLimitNumberOfRequestTest_Fails()
770769
}
771770

772771
[Fact]
773-
public async Task GenerateBombardierTestGetBikesInsecureTest_Successfull()
772+
public async Task GenerateBombardierTestGeneratorCreationTest_Success()
774773
{
775-
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
776-
{
777-
options.BombardierNumberOfTotalRequests = 10;
778-
options.BombardierInsecure = true;
779-
options.BombardierUseHttp2 = false;
780-
});
781-
782-
var content = File.ReadAllText("Assets/GetAllBikes.json");
783-
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
784-
785-
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
786-
787-
Assert.NotNull(bombardierTests);
788-
Assert.Single(bombardierTests);
789-
Assert.Contains($@" -m GET https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1 -c 3 --http1 --timeout=30s --duration=5s --insecure --requests=10", bombardierTests.FirstOrDefault().Command);
790-
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
791-
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1", bombardierTests.FirstOrDefault().Url.ToString());
792-
}
793-
794-
[Fact]
795-
public async Task GenerateBombardierTestAddBikeInsecureTest_Successfull()
796-
{
797-
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
798-
{
799-
options.BombardierNumberOfTotalRequests = 10;
800-
options.BombardierInsecure = true;
801-
options.BombardierUseHttp2 = false;
802-
});
803-
804-
var content = File.ReadAllText("Assets/AddBike.json");
774+
var content = File.ReadAllText("Assets/getPetById.json");
805775
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
806776

807-
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
808-
809-
Assert.NotNull(bombardierTests);
810-
Assert.Single(bombardierTests);
811-
Assert.Contains($@" -m POST https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1 -c 3 -H ""Content-Type: application/json"" -b ""{{\""id\"":1,\""name\"":\""Foil\"",\""brand\"":\""Cannondale\""}}"" --http1 --timeout=30s --duration=5s --insecure --requests=10", bombardierTests.FirstOrDefault().Command);
812-
Assert.Equal(HttpMethod.Post, bombardierTests.FirstOrDefault().Method);
813-
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1", bombardierTests.FirstOrDefault().Url.ToString());
814-
}
815-
816-
[Fact]
817-
public async Task GenerateBombardierTestDoesNotEndWithNewLineTest1_Successfull()
818-
{
819-
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
820-
{
821-
options.BombardierNumberOfTotalRequests = 10;
822-
options.BombardierInsecure = true;
823-
options.BombardierUseHttp2 = false;
824-
});
825-
826-
var content = File.ReadAllText("Assets/AddBike.json");
827-
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
777+
var bombardierTestsGenerator = new BombardierTestsGenerator(httpRequest);
828778

829-
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
779+
var bombardierTests = await bombardierTestsGenerator.Generate();
830780

831781
Assert.NotNull(bombardierTests);
832782
Assert.Single(bombardierTests);
833-
Assert.Contains($@" -m POST https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1 -c 3 -H ""Content-Type: application/json"" -b ""{{\""id\"":1,\""name\"":\""Foil\"",\""brand\"":\""Cannondale\""}}"" --http1 --timeout=30s --duration=5s --insecure --requests=10", bombardierTests.FirstOrDefault().Command);
834-
Assert.Equal(HttpMethod.Post, bombardierTests.FirstOrDefault().Method);
835-
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1", bombardierTests.FirstOrDefault().Url.ToString());
836-
Assert.DoesNotContain(Environment.NewLine, bombardierTests.FirstOrDefault().Command);
783+
Assert.Contains(" -m GET https://petstore3.swagger.io/api/v3/pet/10 -c 3 --http2 --timeout=30s --duration=10s", bombardierTests.FirstOrDefault().Command);
784+
Assert.Equal(HttpMethod.Get, bombardierTests.FirstOrDefault().Method);
785+
Assert.Equal("https://petstore3.swagger.io/api/v3/pet/10", bombardierTests.FirstOrDefault().Url.ToString());
837786
}
838787

839788
[Fact]
840-
public async Task GenerateBombardierTestDoesNotEndWithNewLineTest2_Successfull()
789+
public void GenerateBombardierTestGeneratorCreationTest_Fails()
841790
{
842-
var bombardierTestsGenerator = new BombardierTestsGenerator(options =>
843-
{
844-
options.BombardierNumberOfTotalRequests = 10;
845-
options.BombardierInsecure = true;
846-
options.BombardierUseHttp2 = false;
847-
});
848-
849-
var content = File.ReadAllText("Assets/AddBike.json");
791+
var content = File.ReadAllText("Assets/getPetById.json");
850792
var httpRequest = JsonConvert.DeserializeObject<IEnumerable<HttpRequest>>(content);
851793

852-
var bombardierTests = await bombardierTestsGenerator.Generate(httpRequest);
853-
854-
Assert.NotNull(bombardierTests);
855-
Assert.Single(bombardierTests);
856-
Assert.Contains($@" -m POST https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1 -c 3 -H ""Content-Type: application/json"" -b ""{{\""id\"":1,\""name\"":\""Foil\"",\""brand\"":\""Cannondale\""}}"" --http1 --timeout=30s --duration=5s --insecure --requests=10", bombardierTests.FirstOrDefault().Command);
857-
Assert.Equal(HttpMethod.Post, bombardierTests.FirstOrDefault().Method);
858-
Assert.Equal("https://qatoolkitapi.azurewebsites.net/api/bicycles?api-version=1", bombardierTests.FirstOrDefault().Url.ToString());
859-
Assert.DoesNotContain(Environment.NewLine, bombardierTests.FirstOrDefault().Command);
794+
Assert.Throws<ArgumentNullException>(() => new BombardierTestsGenerator(null));
860795
}
861796
}
862797
}

src/QAToolKit.Engine.Bombardier.Test/BombardierTestsRunnerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.Extensions.Logging;
22
using Newtonsoft.Json;
33
using QAToolKit.Core.Models;
4-
using QAToolKit.Core.Test;
54
using System;
65
using System.Collections.Generic;
76
using System.IO;
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
using System;
22
using Xunit;
33

4-
public sealed class IgnoreOnGithubFact : FactAttribute
4+
namespace QAToolKit.Engine.Bombardier.Test
55
{
6-
public IgnoreOnGithubFact()
6+
public class IgnoreOnGithubFact : FactAttribute
77
{
8-
if (IsGitHubAction())
8+
public IgnoreOnGithubFact()
99
{
10-
Skip = "Ignore the test when run in Github agent.";
10+
if (IsGitHubAction())
11+
{
12+
Skip = "Ignore the test when run in Github agent.";
13+
}
1114
}
12-
}
1315

14-
private static bool IsGitHubAction()
15-
=> Environment.GetEnvironmentVariable("GITHUB_ACTION") != null;
16+
private static bool IsGitHubAction()
17+
=> Environment.GetEnvironmentVariable("GITHUB_ACTION") != null;
18+
}
1619
}

src/QAToolKit.Engine.Bombardier.Test/QAToolKit.Engine.Bombardier.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
6-
<IsPackable>false</IsPackable>
5+
<LangVersion>latest</LangVersion>
6+
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
@@ -13,7 +13,7 @@
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201020-06" />
1717
<PackageReference Include="xunit" Version="2.4.1" />
1818
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1919
<PrivateAssets>all</PrivateAssets>
@@ -52,5 +52,4 @@
5252
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
5353
</None>
5454
</ItemGroup>
55-
5655
</Project>

src/QAToolKit.Engine.Bombardier.Test/XunitLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System;
33
using Xunit.Abstractions;
44

5-
namespace QAToolKit.Core.Test
5+
namespace QAToolKit.Engine.Bombardier.Test
66
{
77
public class XunitLoggerProvider : ILoggerProvider
88
{

src/QAToolKit.Engine.Bombardier/BombardierTestsGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using QAToolKit.Core.Interfaces;
2-
using QAToolKit.Core.Models;
1+
using QAToolKit.Core.Models;
32
using QAToolKit.Engine.Bombardier.Helpers;
43
using QAToolKit.Engine.Bombardier.Models;
54
using System;

src/QAToolKit.Engine.Bombardier/Helpers/BombardierSwitchGeneratorHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static string GenerateInsecureSwitch(BombardierGeneratorOptions bombard
3232
/// <returns></returns>
3333
internal static string GenerateTotalRequestsSwitch(BombardierGeneratorOptions bombardierOptions)
3434
{
35-
if(bombardierOptions.BombardierRateLimit != null &&
35+
if (bombardierOptions.BombardierRateLimit != null &&
3636
bombardierOptions.BombardierNumberOfTotalRequests != null)
3737
{
3838
throw new QAToolKitBombardierException("BombardierRateLimit and BombardierNumberOfTotalRequests settings are mutually exclusive. Please use one or the other.");

0 commit comments

Comments
 (0)