QA Guides

Rest test is an in-house custom tool written in C#, used primarily for continually running integration tests against REST api endpoints. Although its primary use is continuous testing of api endpoints, the tool also supports:

  • SOAP communication
  • performance testing mode
  • smoke testing mode
  • reporting results into either:
    • standalone HTML report
    • Azure Log Analytics Workspace with Azure Workbook used to visualize those results

Tests

Tests are written using fluent interface. Following is an example of a single test case.

Test case example

The example above does the following in this order:

  • targets service called "UsersService" in configuration
  • picks random number and stores it as variable called "RandomUserId"
  • sends HTTP request, references variable "RandomUserId"
  • verifies that the HTTP request returned status code 200

When reporting results, Rest test reports result of each test step, including their detail (e.g. HTTP request and response). This simplifies investigations especially when tests are executed remotely.

Test result example

Rest test supports setup and teardown via hooks - test cases with specific name: TestSuitePreHook, TestSuitePostHook, TestCasePreHook and TestCasePostHook

Components

Rest test components

The entire tool consists of:

  • framework for writing tests
  • package containing core functionality
  • engine packages to determine execution mode
  • extension methods for simplified configuration in applications

The tool is made to be extensible, allowing users to create their own custom steps or group steps together into single step; add custom settings and services, etc.


Creating and running tests

How to create test case

Every test case must be part of a test suite. In rest test, test suite is just a public class annotated by RestTestSuite attribute. All test suites must be inside a test library (a c# library project). The entire project must be compiled into a dll. Finally, rest test loads the dll via C# Reflection and runs tests found inside.

Step by step guide:

  1. Create a new project of type 'Class Library'. Make sure that project type is for C#.
  2. Add following nuget package to the project: Hci.RestTest.Core
  3. Add new class - that class will represent the test suite.
  4. In the class add reference to the following namespaces:
    using Hci.RestTest.Core.Framework;
    using Hci.RestTest.Core.Framework.Builders;
    using Hci.RestTest.Core.Framework.Definitions;
    
  5. Make sure that the class is public
  6. Add RestTestSuite attribute above the class. This marks the class for the engine to load.
  7. Add a public method that returns TestDefinition object.
  8. Add RestTest attribute above the method.
  9. To build a test, call RestTestBuilder.CreateTest("name_of_target_host") after which you can chain additional steps.
  10. Finalize the test by calling FinalizeTest method as last step of the test case.
  11. Return the resulting object (TestDefinition) from your test case method.

    Test suite example

How to create an application that can run rest tests

Rest test is using dependency injection to instantiate services registered at application's startup and inject them into the engine and, if needed, into test suites. By default, rest test reads configuration from json files. For those reasons, it is easier to use a Web API-type of project rather than standard console application project. However it is possible to set up rest-test in either project type.

Step by step guide:

  1. Create a new project. This should be some executable application. For example ASP.NET Core Web API project.
  2. Add reference to one of the engine nuget packages. This example will use Hci.RestTest.Engine.Continuous.
  3. In Program.cs class you can register various services as such:

    Rest test setup


    This configuration adds rest-test; the engine for continually running tests; running the engine as a background worker; and reporting results to log analytics workspace.
  4. Remaining setting comes from configuration json files.

Copyright © 2025. All rights reserved.