Make tests faster (#8737)

* Test changes

* Make finding the test tile a little smarter
This commit is contained in:
wrexbe
2022-06-19 20:22:28 -07:00
committed by GitHub
parent bd54b8de25
commit 81e3b2da88
80 changed files with 1769 additions and 1788 deletions

View File

@@ -9,7 +9,7 @@ using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Construction
{
[TestFixture]
public sealed class ConstructionActionValid : ContentIntegrationTest
public sealed class ConstructionActionValid
{
private bool IsValid(IGraphAction action, IPrototypeManager protoMan, out string prototype)
{
@@ -49,9 +49,8 @@ namespace Content.IntegrationTests.Tests.Construction
[Test]
public async Task ConstructionGraphSpawnPrototypeValid()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -82,6 +81,7 @@ namespace Content.IntegrationTests.Tests.Construction
}
}
}
await pairTracker.CleanReturnAsync();
Assert.That(valid, Is.True, $"One or more SpawnPrototype actions specified invalid entity prototypes!\n{message}");
}
@@ -89,9 +89,8 @@ namespace Content.IntegrationTests.Tests.Construction
[Test]
public async Task ConstructionGraphNodeEntityPrototypeValid()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -108,6 +107,7 @@ namespace Content.IntegrationTests.Tests.Construction
message.Append($"Invalid entity prototype \"{node.Entity}\" on node \"{node.Name}\" of graph \"{graph.ID}\"\n");
}
}
await pairTracker.CleanReturnAsync();
Assert.That(valid, Is.True, $"One or more nodes specified invalid entity prototypes!\n{message}");
}
@@ -115,9 +115,8 @@ namespace Content.IntegrationTests.Tests.Construction
[Test]
public async Task ConstructionGraphEdgeValid()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -139,6 +138,7 @@ namespace Content.IntegrationTests.Tests.Construction
}
Assert.That(valid, Is.True, $"One or more edges specified invalid node targets!\n{message}");
await pairTracker.CleanReturnAsync();
}
}
}

View File

@@ -6,7 +6,7 @@ using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Construction
{
[TestFixture]
public sealed class ConstructionPrototypeTest : ContentIntegrationTest
public sealed class ConstructionPrototypeTest
{
// discount linter for construction graphs
// TODO: Create serialization validators for these?
@@ -14,9 +14,8 @@ namespace Content.IntegrationTests.Tests.Construction
[Test]
public async Task TestStartIsValid()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -27,14 +26,14 @@ namespace Content.IntegrationTests.Tests.Construction
Assert.That(graph.Nodes.ContainsKey(start), $"Found no startNode \"{start}\" on graph \"{graph.ID}\" for construction prototype \"{proto.ID}\"!");
}
await pairTracker.CleanReturnAsync();
}
[Test]
public async Task TestTargetIsValid()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -45,14 +44,14 @@ namespace Content.IntegrationTests.Tests.Construction
Assert.That(graph.Nodes.ContainsKey(target), $"Found no targetNode \"{target}\" on graph \"{graph.ID}\" for construction prototype \"{proto.ID}\"!");
}
await pairTracker.CleanReturnAsync();
}
[Test]
public async Task TestStartReachesValidTarget()
{
var server = StartServer();
await server.WaitIdleAsync();
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
@@ -68,6 +67,7 @@ namespace Content.IntegrationTests.Tests.Construction
Assert.That(protoMan.TryIndex(next.Entity, out EntityPrototype entity), $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) specified an invalid entity prototype ({next.Entity})");
Assert.That(entity.Components.ContainsKey("Construction"), $"The next node ({next.Name}) in the path from the start node ({start}) to the target node ({target}) specified an entity prototype ({next.Entity}) without a ConstructionComponent.");
}
await pairTracker.CleanReturnAsync();
}
}
}