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

Hurl will only run first test #593

Closed
bdmorin opened this issue May 24, 2022 · 6 comments · Fixed by #780
Closed

Hurl will only run first test #593

bdmorin opened this issue May 24, 2022 · 6 comments · Fixed by #780
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@bdmorin
Copy link

bdmorin commented May 24, 2022

uname -a                                                                                   
Darwin dredl0ck 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

hurl -V
hurl 1.5.0 libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 1.45.1

I'm feel like this is user error, but for the life of me I can't figure out what I'm doing wrong. I'm trying to write assertions for various domains robots.txt file, and hurl is only running the first test in my hurl file.

robots.hurl

GET https://domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

GET https://staging.domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

GET https://development.domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

GET https://domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

GET https://staging.domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

GET https://development.domain.com/robots.txt

HTTP/* 200
[Asserts]
status < 300

Execution

hurl --test --summary robots.hurl
robots.hurl: RUNNING [1/1]
robots.hurl: SUCCESS
--------------------------------------------------------------------------------
Executed:  1
Succeeded: 1 (100.0%)
Failed:    0 (0.0%)
Duration:  1536ms

So it's only running the first one.

I tried taking out all the tests, and just running the URLS

robots2.hurl
GET https://domain.com/robots.txt
GET https://staging.domain.com/robots.txt
GET https://development.domain.com/robots.txt
GET https://domain.com/robots.txt
GET https://staging.domain.com/robots.txt
GET https://development.domain.com/robots.txt


hurl --progress robots2.hurl                                                           Tue May 24 10:53:15 2022
robots2.hurl: RUNNING [1/1]
robots2.hurl: SUCCESS
# Block all web crawlers from scanning the contact page.

user-agent: *
disallow: /contact
disallow: /contact*.php

# Handle multiple sitemaps:
# - 1 static marketing sitemap (excludes blog content).
# - 1 dynamic blog sitemap.
# Note: this command is only supported by Google, Ask, Bing, and Yahoo search engines.

sitemap: https://www.domain.com/sitemap_index.xml⏎

again, only running the first.

I'd swear this is user error, but it looks like a bug since the docs say you can just list one after another.

Let me know if I can provide more info.

@jcamiel
Copy link
Collaborator

jcamiel commented May 24, 2022

Hi, yes, the documentation and the output is not clear at all: when Hurl output "Executed: n" n is the number of file executed (not the total number of entries in every file). For instance, given this two files:

foo.hurl:

GET https://domain.com/robots.txt

bar.hurl:

GET https://domain.com/robots.txt

If I run:

$ hurl --test foo.hurl bar.hurl

The output will be:

hurl --test foo.hurl bar.hurl
foo.hurl: RUNNING [1/2]
foo.hurl: SUCCESS
bar.hurl: RUNNING [2/2]
bar.hurl: SUCCESS
--------------------------------------------------------------------------------
Executed:  2
Succeeded: 2 (100.0%)
Failed:    0 (0.0%)
Duration:  1536ms

Whereas with the following file:

baz.hurl:

GET https://domain.com/robots.txt
GET https://domain.com/robots.txt

The output will be:

hurl --test --summary baz.hurl
baz.hurl: RUNNING [1/1]
baz.hurl: SUCCESS
--------------------------------------------------------------------------------
Executed:  1
Succeeded: 1 (100.0%)
Failed:    0 (0.0%)
Duration:  1536ms

I agree, we'll improve the docs and Hurl output so everything will be cristal clear,

@jcamiel jcamiel added documentation Improvements or additions to documentation enhancement New feature or request labels May 24, 2022
@bdmorin
Copy link
Author

bdmorin commented May 24, 2022

OH so each .hurl file is an entire test, and multiple gets are for chaining!

I get it now, Thanks! 😸

@bdmorin
Copy link
Author

bdmorin commented May 24, 2022

Hope it's ok to also ask a another question here.

Is it possible to negate a regex search? I'm trying to verify that something DOESN'T exist in a sitemap file, which isn't path compatible.

@jcamiel
Copy link
Collaborator

jcamiel commented May 24, 2022

No problem, you’re welcome to ask!

You can negate all queries, for instance:

GET https://domain.com/robots.txt

HTTP/* 200
[Asserts]
xpath "//urlset/url/loc" not exists
body not matches "\\d{4}-\\d{2}-\\d{2}"

Starting Hurl 1.6.0, you can use regex literal:

GET https://domain.com/robots.txt

HTTP/* 200
[Asserts]
xpath "//urlset/url/loc" not exists
body not matches /\d{4}-\d{2}-\d{2}/

Do you have a response sample and the kind of assert you want to perform ?

@bdmorin
Copy link
Author

bdmorin commented May 24, 2022

I swear I tried that. I'm not at my workstation now, I'll upload my .hurl tomorrow morning.

@jcamiel
Copy link
Collaborator

jcamiel commented May 30, 2022

Hi @bdmorin do you still have any issue ? Don't hesitate to copy/paste your Hurl file and server response, so I can help you,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants