// Copyright 2012-2025 The NATS Authors
// Licensed under the Apache License, Version 2.0
using Xunit.Abstractions;
namespace ZB.MOM.NatsNet.Server.IntegrationTests.Helpers;
///
/// Base class for integration tests that require a running NATS server or cluster.
/// Tests derived from this class are skipped when the infrastructure is not available.
/// These tests correspond to Go's !race build tag tests (TestNoRace* functions).
///
[Trait("Category", "Integration")]
public abstract class IntegrationTestBase
{
protected readonly ITestOutputHelper Output;
///
/// Set to true when the NATS_INTEGRATION_ENABLED environment variable is set to "true".
/// When false, all [SkippableFact] tests will be skipped with an appropriate message.
///
public static readonly bool IntegrationEnabled =
string.Equals(
Environment.GetEnvironmentVariable("NATS_INTEGRATION_ENABLED"),
"true",
StringComparison.OrdinalIgnoreCase);
protected IntegrationTestBase(ITestOutputHelper output)
{
Output = output;
}
///
/// Returns a skip message when integration tests are not enabled.
/// Use with [SkippableFact]: throw new SkipException(SkipMessage) if !IntegrationEnabled.
///
public static string SkipMessage =>
"Integration tests require NATS_INTEGRATION_ENABLED=true and a running NATS server/cluster";
}