-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add ability to define multiple test cases for same endpoint/response #35
Comments
It's good |
Do you think it will be a little unclear if there are too much test case in hooks. Can we order the case in levels? such as
|
I think the names would be clear enough for me with the current format with just differing the names as I described, but I guess it could be put into levels also. I was thinking the current style makes it easy to refactor lines when a single test case endpoint looks the same as a multi test case endpoint. What do you think would look best considering some multi test cases could have considerable amount of before logic (eg. your fixture examples x5 in a before("API"1").case... format vs. just repeated blocks of the current syntax having differing test name. |
You can have a look at #7, what about this style? hook ('GET /path', 'scene 1')
.before (test, done) ->
done()
.after (test, done) ->
done()
hook ('GET /path', 'scene 2')
.before (test, done) ->
done()
.after (test, done) ->
done() |
That works! |
Is there anything we can do to help? Just curious what your estimate would be for completing this change (planning purposes)? |
Hey @cybertk any news on implementing this? |
I started development on previous weekend. Have not much time recently, so the progress is not good. |
@cybertk If a pull request was offered, would you be willing to take it? I'm not sure whether I'll be able to get to it soon, but I might. |
PR is welcome, I'm very appreciated for your contribution. |
I've been thinking about this issue for a bit and I'll layout what I think the issues are and some potential solutions. Issues:
I can see a couple of paths forward. The simplest one is to use something like the
That follows the same conventions that exist today. We could use It doesn't provide a fully hierarchical set of suites. An example where this is an issue: I think that's ok for now as putting it in a second hook file isn't a terrible solution (though I'd probably need a 'skip' function or something similar b/c we might never get a 200 code in that scenario). How does the approach outlined above sound? |
So as I've continued working with abao, I've rethought some things. I think the right way to do this is to adopt an approach like mocha and others have where you have separate suites, and you expose those suites to users. For example:
Suites would be optional so one could do something like:
and that would be equivalent to
or something similar. Unfortunately, I think this means a large rewrite of the hooks infrastructure. I may tackle this in the future but probably not anytime soon. |
Thinking about this some more over the weekend, I think you'd really want to be able to note whether the suite name is or is not part of the route url. |
I think it should be. |
Hi guys, we (with @mik01aj) did some workaround in order to have multiple tests on the same endpoints. https://github.com/lovelybooks/abao it a quick fix while we are waiting for your solution. |
Thanks @ferrylauda |
Hi guys, |
+1 |
Any update on this issue or any workaround. I have tried the workaround mentioned by @ferrylauda but it didn't work for me.
|
Hi @agrover8, Unfortunately we did not implement the feature for "after"-hooks, because we need this temporary solution for multiple test on "before"-hooks only. This is the example how to use multiple tests within "before"-hooks hooks.before('GET /org/{orgid}/test/{sample} -> 200 first test case', function(test, done) {
// your first test case code
});
hooks.before('GET /org/{orgid}/test/{sample} -> 200 second test case', function(test, done) {
// your second test case code
}); |
@ferrylauda Thanks for the reply, but this also not working for me. I did update abao last week. Its v0.4-beta.1 |
+1. Have immediate need for this! Perhaps just implement @ferrylauda's solution for now, |
+1 I guess it's a highly common need. |
@maremmle are your
If that's not working, please post an example of what's not working and I'll take a look. |
Can anybody please post an working example? This is the only issue which is stopping us to use ABAO as API framework. |
Until we get this done, multiple tests per endpoint can be simulated by using different hookfile(s) and rerunning the command. A "less than" solution, but a workaround. |
I have tried the multiple hooks files, but look like abao is reading only On Thu, Mar 3, 2016 at 10:04 AM, plroebuck notifications@github.com wrote:
|
Say if you prefixed your normal run hookfile names with 'basic_', then duplicate one and prefix it with 'alt_'. Put your alternate endpoint test in that file. Do first run specifying |
Means I have run separate command for each hook file. I will try this. |
@agrover8, were you able to test multiple cases using the [edited] workaround described above? |
Currently the test runner generates a test case per endpoint/response defined in the raml. It would be great to be able to define multiple test cases in situations where more thorough testing is desired to feed in slightly modified sample inputs via hooks.
There are several ways to approach this, but here's one thought I had to keep it minimalistic for the test author... We could add test instances during hooks file processing just by defining additional before hooks.
For example, if we have...
GET /endpoint -> 200
Then in the hooks file, to achieve multiple test executions we could specify additional hooks:
before GET /endpoint -> 200 ...
before GET /endpoint -> 200 arbitrary workflow 1 ...
before GET /endpoint -> 200 arbitrary workflow 2 ...
And when the hooks file is processed it could detect there are additional tests and add those into mocha.
The text was updated successfully, but these errors were encountered: