Skip to main content

Timeout & Failures

TimeoutConfig

Every Xcepto test runs within a time budget split into two durations:

ParameterCovers
TotalScenario setup + initialization + state machine execution
TestState machine execution only
var timeout = new TimeoutConfig(
total: TimeSpan.FromSeconds(30),
test: TimeSpan.FromSeconds(25));

await XceptoTest.Given(scenario, timeout, builder =>
{
// ...
});

TimeoutConfig.FromSeconds(total) is a convenience factory that sets test slightly below total when total is at least one second.

Failure types

ExceptionWhen thrown
XceptoTestFailedExceptionAssertion failed in a state
XceptoTimeoutExceptionTotal budget expired before reaching the final state
XceptoScenarioResetExceptionScenario setup or cleanup failed

Testing for expected failures

Use assertThrows / Assert.Throws to verify that a test fails for the right reason in negative-path cases:

[Test]
public void InvalidCredentials_RejectLogin()
{
var scenario = new AuthScenario();

Assert.ThrowsAsync<XceptoTestFailedException>(() =>
XceptoTest.Given(scenario, builder =>
{
var ssr = builder.SsrAdapterBuilder()
.WithBaseUrl(scenario.BaseUri)
.Build();

ssr.Post("/auth/login")
.WithFormContent(
new LoginRequest("user", "wrong-password").ToForm())
.AssertSuccess(); // will fail — login returns 401
}));
}

Choosing timeout values

  • Unit-speed test servers (in-process, no real I/O): total = 5s, test = 3s
  • Integration environments (containers, local services): total = 30s, test = 25s
  • Negative-path tests (expected to time out): use a short test (e.g. 500ms) to keep the suite fast

Define a private static final TimeoutConfig TIMEOUT constant per test class rather than repeating values in every test method.