-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature: Add an optional param to cli to only run requests that have tests #1314
Feature: Add an optional param to cli to only run requests that have tests #1314
Conversation
+1 |
Possibly related: #1039 This PR creates a difference between the way the collections are run in the UI vs the CLI. If this PR is merged, I propose to file a follow-up issue to add a similar option to the UI. However, there are a few questions that this PR raises:
Lastly: This PR promotes a collection-writing-style that I would call "bag-of-requests", where some are used for exploratory-testing, and others are used for automatic testing, and the difference between the two is given implicitly. I would propose a different solution to this problem: In your collection, sort your requests into appropriate subfolders. Then, we should change the runner so that you can do:
I think that would lead to cleaner collections, and give you more flexibility overall. |
@mj-h Yes I do agree that it would be easier to just throw all of the tests into a folder but I don't think that is very realistic for complex collections, such as having a very large API collection which many developers are using & contributing to. It is organized by api routes. The structure would be:
Which matches the url path Now if we wanted to have the CI/CD run the requests only with tests but only for a given folder as you are suggesting (correct me if I am wrong) we run into the issue of the API collection not remaining organized.
Open to suggestions |
(1) I have many tests with assertion only. I have a test with post-script and assertion. The proposed implementation skipped them. (2) The suggested implementation raises the cyclomatic complexity of the code which is not ideal. The implementation involves adding another if/then case, but it is not a recommended approach. Instead, using strategies would be a better option. For instance, we can use a simple strategy (all scripts) and apply different strategies for other cases as needed. |
Asserts were added, @helloanoop let me know if any changes are required, would love to get this in Bruno to allow my team to fully use it! |
@jeff-edmondson-pci you always have the opportunity to build your fork and use your version of Bruno with the features you need. From my point of view, there is at least a lack of documentation correction that would reflect the appearance of new features. I also think it’s right to first discuss the need for any additions before creating a pull request. |
Thanks @jeff-edmondson-pci for working on the PR and @mj-h and @rabestro everyone for chiming in with comments
@mj-h I agree. This is edge case though. We can iteratively improve this logic later by using the decomment library to address this
@mj-h I agree. An assertion is just a "declarative" way of writing a test. I see that this has been addressed in the PR.
The separation is intentional. I agree that both these blocks (post response scripts and test scripts) do the same thing. The intent is to visually separate code related to "scripting" and "tests".
@rabestro This has been addressed in the PR
@rabestro There is a plan to include tags in the roadmap. I think the business use case of Also the @dcoomber @Its-treason @martinsefcik @jeff-edmondson-pci @mj-h @rabestro The PR is GTG from my side. Let me know if you have further comments. I am planning to have this merged over the weekend. |
@@ -215,12 +230,14 @@ const builder = async (yargs) => { | |||
.example( | |||
'$0 run request.bru --output results.xml --format junit', | |||
'Run a request and write the results to results.xml in junit format in the current directory' | |||
); | |||
) | |||
.example('$0 run request.bru --test-only', 'Run all requests that have a test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 214 option name is 'tests-only
here in example 'test-only
@@ -200,6 +211,10 @@ const builder = async (yargs) => { | |||
type: 'boolean', | |||
description: 'Allow insecure server connections' | |||
}) | |||
.option('tests-only', { | |||
type: 'boolean', | |||
description: 'Only run requests that have a test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it runs also in case there are assertions only I would extend this description to be clear when request is executed.
@helloanoop Personally I would rather see in Bruno more "standardized" support for tags instead of this feature. If there would be such support then I guess this |
Thanks everyone for the feedback and comments. I agree that
Its upto the user to ensure that
|
Description
--tests-only
to the CLI arg list. If this is set it will only add request that have tests.Collection
Result
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.