### Install Dependencies and Run Tests Source: https://github.com/kros-sk/teapie/blob/master/CONTRIBUTING.md Install project dependencies using 'dotnet restore' and run tests to ensure the project is set up correctly. ```sh dotnet restore ``` ```sh dotnet test ``` -------------------------------- ### Run Test Case Examples Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/test-case/test-case.md Demonstrates how to run test cases using the `teapie` command. Includes examples for both multi-file (.http) and single-file (.tp) formats. ```sh # Multi-file format teapie "./Tests/002-Cars/002-Edit-Car-req.http" # Single-file format (.tp) teapie "./Tests/002-Cars/004-Car-Operations.tp" ``` -------------------------------- ### Install TeaPie and Skills via AI Agent Prompt Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/ai-agent-skills.md This prompt guides an AI agent to install the TeaPie.Tool globally and then download TeaPie skills for the project. ```text Install TeaPie.Tool globally (if not already installed) and use the `teapie install-skills` command to download TeaPie skills into this project. 1. Install TeaPie.Tool: dotnet tool install -g TeaPie.Tool 2. Download skills: teapie install-skills ``` -------------------------------- ### Start Mock Server Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Starts the mock server for the demo using mockoon-cli. The server runs on http://localhost:3001 by default. Configuration can be modified in server/CarRentalServer.json. ```sh cd demo mockoon-cli start --data ./server/CarRentalServer.json ``` -------------------------------- ### AI Agent Prompt for TeaPie Setup Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/getting-started.md A prompt to guide an AI agent in setting up TeaPie within a project, including installation, skill download, and initialization. ```text Set up TeaPie in this project by following these steps: 1. Install TeaPie.Tool globally (if not already installed): dotnet tool install -g TeaPie.Tool 2. Download TeaPie skills into this project: teapie install-skills 3. Initialize TeaPie configuration: teapie init 4. Ask the user if they want to create their first TeaPie tests. If yes, use the TeaPie skill knowledge to help create appropriate test cases based on their project structure and needs. ``` -------------------------------- ### Install Mockoon CLI Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Installs the Mockoon CLI tool globally using npm. Ensure npm is installed first. ```sh npm install -g @mockoon/cli ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/kros-sk/teapie/blob/master/CONTRIBUTING.md Start a local web server to preview the generated documentation website. The default address is http://localhost:8080. ```sh docfx serve _site ``` -------------------------------- ### Basic Logging Example Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/logging.md Demonstrates how to log an informational message using the application's logger instance. ```csharp tp.Logger.LogInformation("I understand logging in TeaPie! Yee!"); ``` -------------------------------- ### Install TeaPie Skills via CLI Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/ai-agent-skills.md Use this command to download TeaPie skills into your project if TeaPie is already installed. ```sh teapie install-skills ``` -------------------------------- ### Install TeaPie CLI Globally Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/getting-started.md Use this command to install the TeaPie CLI globally on your system. ```sh dotnet tool install -g TeaPie.Tool ``` -------------------------------- ### Install NuGet Package Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/directives.md The #nuget directive installs a specified NuGet package and version for use in your scripts. Remember to use the 'using' directive to access the package's contents. ```csharp #nuget "AutoBogus, 2.13.1" ``` -------------------------------- ### Quick Start: Building and Running TeaPie Application Source: https://github.com/kros-sk/teapie/blob/master/src/TeaPie/README.md Demonstrates how to use the ApplicationBuilder to configure and run the TeaPie application programmatically. This includes setting paths, logging, environment, initialization scripts, and pipelines. ```csharp var appBuilder = ApplicationBuilder.Create(isCollectionRun: true); var app = appBuilder .WithPath("path/to/collection") .WithTemporaryPath("custom/temp/folder") .WithLogging(LogLevel.Information, "path/to/log-file.log", LogLevel.Debug) .WithEnvironment("testlab") .WithEnvironmentFile("path/to/my/environment-file.json") .WithReportFile("path/to/report-file.xml") .WithInitializationScript("path/to/my/init-script.csx") .WithVariablesCaching(false) .WithDefaultPipeline(); // Default pipeline runs tests // .WithStructureExplorationPipeline() - to show structure .Build(); await app.Run(CancellationToken.None); ``` -------------------------------- ### Run All Tests with .NET CLI Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Executes the entire 'Tests' collection using the .NET CLI. This is an alternative if TeaPie.Tool is not installed globally. ```sh cd ./src/TeaPie.DotnetTool dotnet run test "../../demo/Tests" ``` -------------------------------- ### Access Variables Generally Source: https://github.com/kros-sk/teapie/blob/master/proposals/API Proposal.md Demonstrates general methods for checking, setting, getting, and removing variables, which search across all levels. ```csharp if (!tp.ContainsVariable(IsDevlabEnvironment)){ tp.SetVariable("IsDevlabEnvironment", false); } var myVar = tp.GetVariable("IsDevlabEnvironment"); tp.RemoveVariable("IsDevlabEnvironment"); tp.RemoveVariables("Temp-Collection"); // Removes all variables with such a prefix ``` -------------------------------- ### Get TeaPie Help Information Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/collection.md Displays detailed information about all arguments and options available for the TeaPie command-line interface. ```sh teapie --help ``` -------------------------------- ### Example Test in Post-Response Script Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/how-to-write-tests.md Write a basic test in a post-response script to check the status code of an HTTP response. This uses the Xunit.Assert library, with `Equal` being statically imported. ```csharp tp.Test("Status code should be 201.", () => { var statusCode = tp.Response.StatusCode(); Equal(201, statusCode); }); ``` -------------------------------- ### Example Environment File Structure Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/environments.md This JSON structure defines shared variables and environment-specific overrides. '$shared' variables are globally available, while others are specific to an environment like 'local'. ```json { "$shared": { "ApiBaseUrl": "http://my-car-rental-company.com", "ApiCustomersSection": "/customers", "ApiCarsSection": "/cars", "ApiCarRentalSection": "/rental" }, "local": { "ApiBaseUrl": "http://localhost:3001", // Override $shared's variable "DebugMode": true // Environment-specific variable } } ``` -------------------------------- ### Run All Tests with TeaPie Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Executes the entire 'Tests' collection using the TeaPie tool. Assumes TeaPie.Tool is installed. ```sh teapie Tests ``` -------------------------------- ### Add Theoretical Test with Input and Expected Output Source: https://github.com/kros-sk/teapie/blob/master/proposals/API Proposal.md Example of adding a theoretical test, setting input parameters 'm' and 'c', and defining the expected output 'E'. ```csharp tp.AddTestTheory(theory => { theory.Input("m", 100); theory.Input("c", 5); theory.Expected("E", 2500); }); ``` -------------------------------- ### Pack TeaPie Tool Source: https://github.com/kros-sk/teapie/blob/master/CONTRIBUTING.md Pack the TeaPie .NET tool project in Release mode to create a .nupkg file for local installation or distribution. ```sh dotnet pack -c Release ``` -------------------------------- ### Run Single Test Case with .NET CLI Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Executes a specific test case file using the .NET CLI. This is an alternative if TeaPie.Tool is not installed globally. ```sh cd ./src/TeaPie.DotnetTool dotnet run test "../../demo/Tests/002-Cars/002-Edit-Car-req.http" ``` -------------------------------- ### Add Another Theoretical Test Source: https://github.com/kros-sk/teapie/blob/master/proposals/API Proposal.md Another example of adding a theoretical test for the same test case, with different input values for 'm' and 'c'. ```csharp // Another theory for the same test case tp.AddTestTheory(theory => { theory.Input("m", 1); theory.Input("c", 5); theory.Expected("E", 25); }); ``` -------------------------------- ### Using Built-in Functions in HTTP Request Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/functions.md Demonstrates how to use built-in functions like $guid, $now, $randomInt, and $rand to generate dynamic values within an HTTP request body. ```http # Generate values with functions POST https://example.com/api/items Content-Type: application/json { "id": "{{$guid}}", "createdAt": "{{$now "yyyy-MM-dd'T'HH:mm:ss"}}", "score": {{$randomInt 10 20}}, "ratio": {{$rand}} } ``` -------------------------------- ### Execute a Determined Test Source: https://github.com/kros-sk/teapie/blob/master/proposals/API Proposal.md Example of how to execute a determined test case, asserting that the response status code is 200. ```csharp tp.Test("Status Code Should Be 200.", () => { tp.Response.StatusCode.Should().Be().Equal(200); }); ``` -------------------------------- ### Access Variables on Specific Levels Source: https://github.com/kros-sk/teapie/blob/master/proposals/API Proposal.md Demonstrates how to get, check existence of, set, and remove variables on specific levels (Global, Environment, Collection, Scope, Test-Case). ```csharp // Approaching variables var globalVar = tp.GlobalVariables.Get("MyGlobalVariable"); var enviroVar = tp.EnvironmentVariables.Get("MyEnvVariable"); var collVar = tp.CollectionVariables.Get("MyCollectionVariable"); var scopeVar = tp.ScopeVariables.Get("MyScopeVariable"); var testVar = tp.TestCaseVariables.Get("MyTestCaseVariable"); // Checking existence of variables var globalVar = tp.GlobalVariables.Contains("MyGlobalVariable"); var enviroVar = tp.EnvironmentVariables.Contains("MyEnvVariable"); var collVar = tp.CollectionVariables.Contains("MyCollectionVariable"); var scopeVar = tp.ScopeVariables.Contains("MyScopeVariable"); var testVar = tp.TestCaseVariables.Contains("MyTestCaseVariable"); // Altering variables tp.GlobalVariables.Set("MyGlobalVariable", 123); tp.EnvironmentVariables.Set("MyEnvVariable", "Testlab"); tp.CollectionVariables.Set("MyCollectionVariable", true); tp.TestCaseVariables.Set("MyTestCaseVariable", '2024-08-01'); // Removing variables tp.GlobalVariables.Remove("MyGlobalVariable"); tp.EnvironmentVariables.Remove("MyEnvVariable"); tp.CollectionVariables.Remove("MyCollectionVariable"); tp.TestCaseVariables.Remove("MyTestCaseVariable"); ``` -------------------------------- ### Run Single Test Case with TeaPie Source: https://github.com/kros-sk/teapie/blob/master/demo/README.md Executes a specific test case file using the TeaPie tool. This example runs the '002-Edit-Car-req.http' test. ```sh teapie "./Tests/002-Cars/002-Edit-Car-req.http" ``` -------------------------------- ### Single Test Case Example Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/test-case/tp-file.md Defines a single test case with HTTP request and C# script for response validation. Use directives like TEST-EXPECT-STATUS in the HTTP section for status code validation. ```text --- TESTCASE Health Check --- HTTP ## TEST-EXPECT-STATUS: [200] ## TEST-HAS-BODY GET {{ApiBaseUrl}}/health --- TEST tp.Test("Health response should contain status field.", async () => { dynamic responseJson = await tp.Response.GetBodyAsExpandoAsync(); NotNull(responseJson); NotNull(responseJson.status); }); --- END ``` -------------------------------- ### Example PUT Request for Car API Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/how-to-write-tests.md This snippet shows a sample PUT request to the car API, including the endpoint and content type. ```http PUT {{ApiBaseUrl}}{{ApiCarsSection}}/{{AddCarRequest.request.body.$.Id}} Content-Type: {{AddCarRequest.request.headers.Content-Type}} ``` -------------------------------- ### Register Custom Authentication Provider as Default Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/authentication.md Registers a custom authentication provider and sets it as the default for all requests. This simplifies authentication setup when a custom provider is consistently used. ```csharp tp.RegisterDefaultAuthProvider( "MyAuth", new MyAuthProvider(tp.ApplicationContext) .ConfigureOptions(new MyAuthProviderOptions { AuthUrl = authUrl }) ); ``` -------------------------------- ### Example HTTP Request Log Entry Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/requests-logging.md This JSON object represents a single log entry for an HTTP request, including details about the request, response, timing, authentication, and any errors encountered. ```json [ { "Timestamp": "2025-12-03T14:06:09.3239022+01:00", "Level": "Information", "MessageTemplate": "{@RequestLogFileEntry}", "Properties": { "RequestLogFileEntry": { "RequestId": "28ccf092-0240-4d91-8acc-108ef45c8acb", "StartTime": "2025-12-03T13:06:09.1820864Z", "EndTime": "2025-12-03T13:06:09.3237782Z", "DurationMs": 141.6918, "Request": { "Name": "GetEditedCarRequest", "Method": "GET", "Uri": "http://localhost:3001/cars/6", "Headers": { "Authorization": "Bearer authToken" }, "Body": "", "ContentType": "text/plain", "FilePath": "002-Cars\002-Edit-Car-req.http", "_typeTag": "RequestInfo" }, "Response": { "StatusCode": 200, "ReasonPhrase": "OK", "Headers": { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS", "Access-Control-Allow-Headers": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With", "Date": "Wed, 03 Dec 2025 13:06:09 GMT", "Connection": "keep-alive", "Keep-Alive": "timeout=5" }, "Body": "{\"Id\":6,\"Brand\":\"Toyota\",\"Model\":\"RAV4\",\"EngineType\":\"3.0 TDI\",\"TransmissionType\":\"Manual\",\"PeopleCapacity\":5,\"Color\":\"silver\",\"Year\":2022,\"DrivenKilometres\":21000,\"Description\":\""}", "ContentType": "application/json", "ReceivedAt": "2025-12-03T13:06:09.3238287Z", "_typeTag": "ResponseInfo" }, "Authentication": { "ProviderType": "OAuth2Provider", "IsDefault": true, "AuthenticatedAt": "2025-12-03T13:06:09.3238312Z", "_typeTag": "AuthInfo" }, "Errors": [], "_typeTag": "RequestLogFileEntry" }, "SourceContext": "HttpRequests", "HttpMethod": "GET", "Uri": "http://localhost:3001/cars/6", "Scope": [ "HTTP GET http://localhost:3001/cars/6" ] } } ] ``` -------------------------------- ### Initialize TeaPie project Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/commands.md Prepare your working directory for TeaPie by running the `init` command. This creates a `.teapie` folder and updates `.gitignore`. An optional path can be provided for the `.teapie` folder. ```sh teapie init [path-to-teapie-folder] [--no-logo] ``` -------------------------------- ### Build Documentation with DocFX Source: https://github.com/kros-sk/teapie/blob/master/CLAUDE.md Commands to build and serve documentation using DocFX. ```sh docfx "./docs/docfx.json" docfx serve _site ``` -------------------------------- ### Generate Documentation Website Source: https://github.com/kros-sk/teapie/blob/master/CONTRIBUTING.md Generate the static website output for the documentation by running DocFX on the specified configuration file. ```sh docfx "./docs/docfx.json" ``` -------------------------------- ### Set up Local NuGet Feed Source: https://github.com/kros-sk/teapie/blob/master/CONTRIBUTING.md Create a new directory for a local NuGet feed and add it as a source in your NuGet configuration. This is useful for local development and testing. ```sh mkdir "path/to/your/new/local/feed/directory" dotnet nuget add source "path/to/your/local/feed" --name LocalNuGetFeed ``` -------------------------------- ### Explore Collection or Test Case Source: https://github.com/kros-sk/teapie/blob/master/docs/docs/commands.md Use the `explore` command to explore a collection, request file (.http), or test case (.tp). It allows specifying an environment file and an initialization script. ```sh teapie explore [path] [--log-file ] [--log-file-log-level ] [-l|--log-level ] [-d|--debug] [-v|--verbose] [-q|--quiet] [--env-file ] [--init-script