Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API - Testing #4

Open
matejicko opened this issue Aug 7, 2024 · 1 comment
Open

API - Testing #4

matejicko opened this issue Aug 7, 2024 · 1 comment
Labels
proposal Proposal of some functionality

Comments

@matejicko
Copy link
Collaborator

Tests within this framework can be divided into two categories:

  • Determined tests - without possibility to input parameters
  • Theoretical tests - these tests are represented by testing scenario(s) with custom parameters

Determined tests

API

public void Test(string testName, Action testFunction);
public async Task Test(string testName, Func<Task> testFunction); // Asynchronous test

Examples of usage

tp.Test("Status Code Should Be 200.", () => {
    tp.Response.StatusCode.Should().Be().Equal(200);
});

Theoretical tests (Scenarios)

API

public void AddTestTheory(Action<Theory> testFunction);
public void AddTestTheory(string testName, Action<Theory> testFunction);

Examples of usage

tp.AddTestTheory(theory => {
    theory.Input<int>("m", 100); // Input parameter 'm' is set to 100
    theory.Input<int>("c", 5); // Input parameter 'c' is set to 5

    theory.Expected<int>("E", 2500); // Parameter 'E' is expected to be 2 500, after request execution
});

// Another theory for the same test case
tp.AddTestTheory(theory => {
    theory.Input<int>("m", 1);
    theory.Input<int>("c", 5);

    theory.Expected<int>("E", 25);
});

Method tp.Test() will be called in the post-response scripts in the most cases. Althought, there is no problem to use this method within pre-request script - e.g. when you want to check the state before request execution.

On the other hand method tp.AddTestTheory() must be located in pre-request script, other-wise it will be ignored.

@matejicko matejicko added the proposal Proposal of some functionality label Aug 7, 2024
@matejicko matejicko changed the title Testing API API - Testing Module Aug 7, 2024
@matejicko matejicko changed the title API - Testing Module API - Testing Aug 7, 2024
@matejicko
Copy link
Collaborator Author

Determined tests were implemented in #33.
Theories will be added later for their complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal of some functionality
Projects
None yet
Development

No branches or pull requests

1 participant