DotHttpTest 3.1.2
dotnet add package DotHttpTest --version 3.1.2
NuGet\Install-Package DotHttpTest -Version 3.1.2
<PackageReference Include="DotHttpTest" Version="3.1.2" />
<PackageVersion Include="DotHttpTest" Version="3.1.2" />
<PackageReference Include="DotHttpTest" />
paket add DotHttpTest --version 3.1.2
#r "nuget: DotHttpTest, 3.1.2"
#:package DotHttpTest@3.1.2
#addin nuget:?package=DotHttpTest&version=3.1.2
#tool nuget:?package=DotHttpTest&version=3.1.2
dothttptest
.NET Test Framework for API tests with .http files
Supporting HTTP and MCP
Why another HTTP test framework?
I like .http files. They make development and debugging easy. With integration in VS Code, Visual Studio and Rider I like that I don't have to leave my editor to run them.
They are simple and efficient. Can be shared within the development team. They can be shared with a QA team.
As a developer, I also don't like duplicating work. I was searching for a test framework where I can re-use my .http files for API testing, but I didn't find anything that allowed me to do it using C#.
MCP
To test MCP, set the VERSION in the request header to MCP
The syntax for MCP is using a syntax similar to HTTP, but internally the framework uses the ModelContextProtocol to actually call tools.
MCP Transport Mode
You can specify the transport mode by setting the VERSION
header to MCP/mode
in the request.
Example:
- MCP/SSE uses SSE (HttpTransportMode.Sse)
- MCP/HTTP uses streamable HTTP (HttpTransportMode.StreamableHttp)
- MCP/AUTO uses automatic (HttpTransportMode.AutoDetect)
Default is automatic
Additional HTTP request headers
If you want to add an additional HTTP header to the request, for example an Authorization header you can add it in the same syntax as for HTTP requests
CALL http://localhost:4723/mcp#browser_navigate MCP
Authorization: Bearer TOKEN_GOES_HERE
{
"url": "https://www.github.com"
}
List tools
LIST http://localhost/mcp MCP
This will list tool available from the MCP server (IMcpClient.ListToolsAsync). The response will be serialized as json and can be verified with the "json" verifier or the "tool" verifier.
Verify that a tool exists
# @verify tool browser_close exists
LIST http://localhost/mcp MCP
The "tool" verifier will evaluate the MCP ListToolsResult . This example will check if there is a tool with the name "browser_close" in the result.
Verify a tool parameter is defined in the inputSchema for a specific tool
# @verify tool browser_navigate.inputSchema.properties.url exists
# @verify tool browser_navigate.inputSchema.properties.url.type == string
LIST http://localhost/mcp MCP
The "tool" verifier expects the tool name to be specified in the @verify command. It may be followed by:
- inputSchema
- outputSchema
- annotations
- meta
- title
- description
title and description are strings, and can be evaluated directly as value types:
# @verify tool browser_navigate.title exists
# @verify tool browser_navigate.description contains Navigates
inputSchema, outputSchema, annotations and meta are objects, and can be evaluated using JSON path syntax
Using json verifier for MCP tool listing
You can also use the json verifier for advanced evaluation of the list tools result. The content of the tool listing is an array of tools according to MCP schema.
Invoke a MCP tool
To call a tool use the CALL method with the tool name in the request URL after a #
CALL http://localhost/mcp#browser_close MCP
Invoke a tool with parameters
To invoke a tool with parameters, use the CALL method with the tool name in the request URL after a # and pass the parameters in the body of the request:
CALL http://localhost/mcp#browser_navigate MCP
{
"url": "https://www.github.com"
}
Verification of MCP tool invocation
# @verify mcp success
# @verify mcp textContent contains ### Ran Playwright code
CALL http://localhost/mcp#browser_navigate MCP
{
"url": "https://www.github.com"
}
Extensions in .http file
dothttptest supports extensions in the form of .http file comments, allowing the same file to be used within existing tools without breaking compliance, while also allowing automating tests with the same file. All extensions including those that add verification checks are added as instructions within a comment similarily to how some .http formats allow setting a name for a request:
# @name MyRequestName
GET http://localhost/get HTTP/1.1
Verification checks within .http files
A verification check can be added in a similar way to @name by using the @verify command:
# @verify http status-code 200
GET http://localhost/get HTTP/1.1
The @verify command is followed by the module performing the verification. Additional modules can be added to support additional checks.
Verifiers can be created in code:
[ResponseVerifier("myVerifier")]
public class MyVerifier : IVerifier
{
public void Verify(DotHttpResponse response, VerificationCheckResult result)
{
// ...
}
}
.. and used within the .http file by speciying the same name as was specified in code on the ResponseVerifier attribute on the class.
Verify that an HTTP header exists in the response
# @verify header content-type exists
GET http://localhost/get HTTP/1.1
Verify that an HTTP header value exists in a response
# @verify header accept-ranges == bytes
GET http://localhost/get HTTP/1.1
Verify a JSON property
# @verify json PropertyName == Value
GET http://localhost/get HTTP/1.1
Use a JSON property in the next request
GET http://localhost/get HTTP/1.1
PATCH http://localhost/post/{{$json.PropertyName}}
{
"UpdatedField": "123"
}
Usage
CLI Example Usage
$ dothttp run <httpfile>
CLI will run the requests specified in the .http and generate a junit-xml as output.
Adding .NET package
Add package using .NET CLI
dotnet add package DotHttpTest
C# Example Usage
Running all requests in a .http file and getting the result
using DotHttpTest;
var runner = new TestPlanRunnerOptionsBuilder()
.LoadHttpFile(pathToHttpFile)
.Build();
var testStatus = await runner.RunAsync();
Console.WriteLine($"Requests failed: {testStatus.HttpRequestFails.Value} / {testStatus.HttpRequests.Value}");
Running a single request
using DotHttpTest;
using var client = new DotHttpClient();
var requests = client.LoadFile("testfile.http");
var request = requests.First();
var response = await client.SendAsync(request);
System.Net.Http.HttpResponseMessage httpResponse = response.AsHttpResponseMessage();
Console.WriteLine($"{httpResponse.IsSuccessStatusCode}");
Running stress, soak and iterative tests
dothttptest implements stress and soak inspired by K6. Stages can be defined on a request including concurrency (virtual users) and a duration.
# @stage ramp-up duration:20s target:10
# @stage main duration:10m target:10
# @stage ramp-down duration:20s target:0
GET http://localhost/get HTTP/1.1
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- FluentAssertions (>= 7.2.0)
- Microsoft.Extensions.Http (>= 9.0.7)
- ModelContextProtocol (>= 0.3.0-preview.3)
- Newtonsoft.Json (>= 13.0.3)
- TestBucket.Traits.Core (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
3.1.2 | 172 | 8/5/2025 |
3.1.0 | 125 | 8/4/2025 |
3.0.2 | 492 | 3/29/2025 |
3.0.1 | 137 | 3/28/2025 |
3.0.0 | 157 | 3/27/2025 |
2.1.1 | 125 | 8/4/2025 |
2.1.0 | 105 | 8/4/2025 |
2.0.5 | 182 | 7/1/2024 |
2.0.4 | 132 | 7/1/2024 |
2.0.3 | 134 | 6/28/2024 |
2.0.2 | 131 | 6/28/2024 |
2.0.1 | 131 | 6/28/2024 |
2.0.0 | 137 | 6/28/2024 |
1.5.2 | 134 | 6/28/2024 |
1.5.0 | 130 | 6/28/2024 |
1.4.0 | 168 | 3/15/2024 |
1.3.6 | 162 | 3/14/2024 |
1.3.5 | 148 | 3/8/2024 |
1.3.4 | 157 | 3/8/2024 |
1.3.3 | 147 | 3/8/2024 |
1.3.2 | 146 | 3/8/2024 |
1.3.1 | 140 | 3/7/2024 |
1.3.0 | 135 | 3/7/2024 |
1.2.8 | 136 | 3/7/2024 |
1.2.7 | 139 | 3/7/2024 |
1.2.6 | 153 | 2/20/2024 |
1.2.5 | 148 | 2/20/2024 |
1.2.4 | 264 | 12/5/2023 |
1.2.3 | 151 | 12/4/2023 |
1.2.2 | 158 | 12/4/2023 |
1.2.1 | 173 | 12/4/2023 |
1.2.0 | 170 | 12/1/2023 |
1.1.0 | 216 | 8/21/2023 |
1.0.11 | 198 | 8/21/2023 |
1.0.10 | 189 | 8/21/2023 |
1.0.9 | 198 | 8/21/2023 |
1.0.8 | 188 | 8/21/2023 |
1.0.7 | 206 | 6/16/2023 |
1.0.6 | 217 | 6/12/2023 |
1.0.5 | 207 | 6/12/2023 |
1.0.4 | 200 | 6/11/2023 |
1.0.3 | 209 | 6/11/2023 |
1.0.2 | 215 | 6/11/2023 |
1.0.1 | 196 | 6/11/2023 |
1.0.0 | 193 | 6/11/2023 |