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

The assertions are not being verified. #11

Open
Marek00Malik opened this issue Jul 18, 2022 · 7 comments
Open

The assertions are not being verified. #11

Marek00Malik opened this issue Jul 18, 2022 · 7 comments
Assignees

Comments

@Marek00Malik
Copy link

I'm trying to use this tool to run tests outside of my IDE in CICD. So far the called are executed, but the problem I have is that non of my assertions are being tested at all.

Bellow the simplest test for your HTTP example:

### get my ip
//@name get-my-ip
GET https://httpbin.org/ip

> {%
    client.test("Request executed successfully", function() {
        client.log(response.status);
        client.log(response.contentType);
        client.log(response.body);
        client.log("Testing");
        client.assert(response.status == 400, "this should fail");
        client.assert(true, "this should not fail");
    });
%}

Expected result:

Exactly as in IntelliJ, I would imagine the tool to fail/return non zero error code.

@Marek00Malik
Copy link
Author

➜ httpx --version
0.33.0

@linux-china linux-china self-assigned this Jul 18, 2022
@linux-china
Copy link
Collaborator

Now client.assert just calls console.assert(), and code assert following:

    assert(condition, message) {
        console.assert(condition, message);
    }

You mean if assertion failed, and exit httpx and return none zero error code like following:

  assert(condition, message) {
        if(!condition) {
           console.error(message);
           process.exit(1);
        }
    }

@Marek00Malik
Copy link
Author

if I would assume to get some error code when the assertion is failing.
This is working when running with docker.

@linux-china
Copy link
Collaborator

I can add -W for this feature, and it means warning. If assertion failed, and httpx will exit with none zero code.

@tino-fernandez
Copy link

thanks @linux-china i'll try that option, but i am wondering, if this is a testing tool to automate checks, should that not be the default behaviour?

@linux-china
Copy link
Collaborator

-W not available now, and I will implement this week.

if this is a testing tool to automate checks, should that not be the default behaviour?

Because this behaviour is different with HTTP Client in IDE. But it's ok to add -W option for CLI. :)

@mis4s
Copy link

mis4s commented Nov 21, 2022

Hi, any update on this? I would love to see this feature for our CI/CD processes

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

No branches or pull requests

4 participants