Create 7 helper files under ZB.MOM.NatsNet.Server.IntegrationTests/Helpers/ and add Xunit.SkippableFact package. All tests skip gracefully via IntegrationTestBase.CanBoot() guard until the .NET server runtime is complete.
58 lines
2.4 KiB
C#
58 lines
2.4 KiB
C#
// Copyright 2012-2026 The NATS Authors
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
namespace ZB.MOM.NatsNet.Server.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// Abstract base class for all integration tests.
|
|
/// Skips the entire test class if the server cannot boot (i.e., the .NET server
|
|
/// runtime is not yet complete). Individual test classes inherit from this class.
|
|
/// </summary>
|
|
[Trait("Category", "Integration")]
|
|
public abstract class IntegrationTestBase : IDisposable
|
|
{
|
|
// =========================================================================
|
|
// Constructor — Skip guard
|
|
// =========================================================================
|
|
|
|
/// <summary>
|
|
/// Initializes the test base and verifies that the server can boot.
|
|
/// If <see cref="Helpers.TestServerHelper.CanBoot()"/> returns false the test
|
|
/// is skipped via <c>Xunit.SkippableFact</c>'s <c>Skip.If</c> mechanism.
|
|
/// </summary>
|
|
protected IntegrationTestBase(ITestOutputHelper output)
|
|
{
|
|
Output = output;
|
|
Skip.If(!Helpers.TestServerHelper.CanBoot(), "Server cannot boot — skipping integration tests.");
|
|
}
|
|
|
|
// =========================================================================
|
|
// Protected members
|
|
// =========================================================================
|
|
|
|
/// <summary>xUnit output helper, available to derived test classes.</summary>
|
|
protected ITestOutputHelper Output { get; }
|
|
|
|
// =========================================================================
|
|
// IDisposable
|
|
// =========================================================================
|
|
|
|
/// <summary>
|
|
/// Override in subclasses to perform per-test cleanup (e.g., shut down servers,
|
|
/// delete temp dirs). The base implementation does nothing.
|
|
/// </summary>
|
|
public virtual void Dispose() { }
|
|
}
|