Skip to content

Commit 2b51d3e

Browse files
committed
Rework IntegrationTestAttribute to allow for multiple instances, carry a flag whether it can be run on CI, don't yield the trait if it can't.
1 parent 08fd58e commit 2b51d3e

File tree

9 files changed

+25
-16
lines changed

9 files changed

+25
-16
lines changed

test/Providers.GremlinServer.Tests/IntegrationAndDeserializationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
66
{
7-
[IntegrationTest("Windows", "Linux")]
7+
[IntegrationTest("Linux")]
8+
[IntegrationTest("Windows", false)]
89
public sealed class IntegrationAndDeserializationTests : QueryExecutionTest, IClassFixture<GremlinServerContainerFixture>
910
{
1011
public IntegrationAndDeserializationTests(GremlinServerContainerFixture fixture) : base(

test/Providers.GremlinServer.Tests/IntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
1313
{
14-
[IntegrationTest("Windows", "Linux")]
14+
[IntegrationTest("Linux")]
15+
[IntegrationTest("Windows", false)]
1516
public sealed class IntegrationTests : QueryExecutionTest, IClassFixture<GremlinServerContainerFixture>
1617
{
1718
public IntegrationTests(GremlinServerContainerFixture fixture) : base(

test/Providers.GremlinServer.Tests/IntegrationWithoutProjectionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
66
{
7-
[IntegrationTest("Windows", "Linux")]
7+
[IntegrationTest("Linux")]
8+
[IntegrationTest("Windows", false)]
89
public sealed class IntegrationWithoutProjectionTests : QueryExecutionTest, IClassFixture<GremlinServerWithoutProjectionContainerFixture>
910
{
1011
public IntegrationWithoutProjectionTests(GremlinServerWithoutProjectionContainerFixture fixture) : base(

test/Providers.GremlinServer.Tests/PasswordSecuredIntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
66
{
7-
[IntegrationTest("Windows", "Linux")]
7+
[IntegrationTest("Linux")]
8+
[IntegrationTest("Windows", false)]
89
public sealed class PasswordSecuredIntegrationTests : QueryExecutionTest, IClassFixture<PasswordSecuredGremlinServerContainerFixture>
910
{
1011
public PasswordSecuredIntegrationTests(PasswordSecuredGremlinServerContainerFixture fixture) : base(

test/Providers.GremlinServer.Tests/WrongPasswordIntegrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
namespace ExRam.Gremlinq.Providers.GremlinServer.Tests
1515
{
16-
[IntegrationTest("Windows", "Linux")]
16+
[IntegrationTest("Linux")]
17+
[IntegrationTest("Windows", false)]
1718
public sealed class WrongPasswordIntegrationTests : GremlinqTestBase, IClassFixture<WrongPasswordGremlinServerContainerFixture>
1819
{
1920
public sealed class WrongPasswordGremlinServerContainerFixture : DockerfileTestContainerFixture
@@ -22,7 +23,6 @@ public WrongPasswordGremlinServerContainerFixture() : base("PasswordSecureGremli
2223
{
2324
}
2425

25-
2626
protected override async Task<IGremlinQuerySource> TransformQuerySource(IContainer container, IGremlinQuerySource g) => g
2727
.UseGremlinServer<Vertex, Edge>(_ => _
2828
.At(new UriBuilder("ws", container.Hostname, container.GetMappedPublicPort(8182)).Uri)

test/Providers.JanusGraph.Tests/IntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
namespace ExRam.Gremlinq.Providers.JanusGraph.Tests
88
{
9-
[IntegrationTest("Windows", "Linux")]
9+
[IntegrationTest("Linux")]
10+
[IntegrationTest("Windows", false)]
1011
public sealed class IntegrationTests : QueryExecutionTest, IClassFixture<JanusGraphContainerFixture>
1112
{
1213
public new sealed class Verifier : JTokenExecutingVerifier

test/Providers.Neptune.Tests/IntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace ExRam.Gremlinq.Providers.Neptune.Tests
66
{
7-
[IntegrationTest("Windows", "Linux")]
7+
[IntegrationTest("Linux")]
8+
[IntegrationTest("Windows", false)]
89
public sealed class IntegrationTests : QueryExecutionTest, IClassFixture<NeptuneContainerFixture>
910
{
1011
public IntegrationTests(NeptuneContainerFixture fixture) : base(

test/Tests.Infrastructure/Traits/IntegrationTestAttribute.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace ExRam.Gremlinq.Tests.Infrastructure
44
{
55
[TraitDiscoverer("ExRam.Gremlinq.Tests.Infrastructure.IntegrationTestDiscoverer", "ExRam.Gremlinq.Tests.Infrastructure")]
6-
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
6+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
77
public sealed class IntegrationTestAttribute : Attribute, ITraitAttribute
88
{
9-
public IntegrationTestAttribute(params string[] validPlatforms)
9+
public IntegrationTestAttribute(string validPlatform, bool canRunOnCI = true)
1010
{
11-
ValidPlatforms = validPlatforms;
11+
ValidPlatform = validPlatform;
1212
}
1313

14-
public string[] ValidPlatforms { get; }
14+
public bool CanRunOnCI { get; }
15+
public string ValidPlatform { get; }
1516
}
1617
}

test/Tests.Infrastructure/Traits/IntegrationTestDiscoverer.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ public class IntegrationTestDiscoverer : ITraitDiscoverer
66
{
77
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
88
{
9+
var isCi = bool.TryParse(Environment.GetEnvironmentVariable("CI"), out var ci)
10+
? ci
11+
: false;
12+
913
yield return new KeyValuePair<string, string>("Category", "IntegrationTest");
1014

1115
if (traitAttribute is ReflectionAttributeInfo { Attribute: IntegrationTestAttribute integrationTestAttribute })
1216
{
13-
foreach (var validPlatform in integrationTestAttribute.ValidPlatforms)
14-
{
15-
yield return new KeyValuePair<string, string>("ValidPlatform", validPlatform);
16-
}
17+
if (integrationTestAttribute.CanRunOnCI || !isCi)
18+
yield return new KeyValuePair<string, string>("ValidPlatform", integrationTestAttribute.ValidPlatform);
1719
}
1820
}
1921
}

0 commit comments

Comments
 (0)