GithubHelp home page GithubHelp logo

Hook file is not working about abao HOT 15 CLOSED

agrover8 avatar agrover8 commented on June 2, 2024
Hook file is not working

from abao.

Comments (15)

cybertk avatar cybertk commented on June 2, 2024

What is your problem?

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk
In my hook file, I have provided two different cases for resource 'GET /org/15602/activity/{activityid} -> 200'

Both the cases have incorrect activityid, so I am expecting these test cases should be fail.

But when I am running the following command all the test passed.
$ abao origin_new.raml https://test.com/ssvui --hookfiles=hook.coffee

So to debug this I just ran the raml file without hook file:
$ abao origin_new.raml https://test.com/ssvui

Result of the above command is also same as the first command, so its look like abao is not reading hook file. Though it says: Found Hookfiles: hook.coffee

Please let me know if you need more information.

from abao.

cybertk avatar cybertk commented on June 2, 2024

You can define only one test for each case(response code) in Abao. So for your case, you defined two tests/hooks for GET /org/15602/activity/{activityid} -> 200, only one is used and the other one is ignored.

If you want test the error case of your API, you should define it in your RAML. e.g. Your API will response 400 if activityid is not a number with

responses:
          200:
            ...
          400:
           ...

I think Abao should print a warning message for your case, what's your advice?

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk

  1. If that is the case then why the first case 'GET /j_spring_security_check -> 302', (test, done) -> is getting pass where in Hook file I have entered incorrect login and RAML has correct login.
  2. How can i test multiple test cases for one case?

For example,
I have one resource GET /org/15602/activity/{activityid} -> 200, and I want to test this resource with 3 different activityid where the response code for all 3 cases is 200.

from abao.

cybertk avatar cybertk commented on June 2, 2024
  1. Each test case is identified by Test Name, such as GET /j_spring_security_check -> 302.
  2. Abao does not support this feature now.

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk
If we can define only one test for each case(response code) in Abao. So the test mentioned in the Hook file run for that particular resuource, right?
Example:
RAML file has activityid 12345*** for GET /org/15602/activity/{activityid} -> 200
and
Hook file has activityid 567*** for GET /org/15602/activity/{activityid} -> 200

Abao test will run with activityid 567*** (Hook file), is that correct?

from abao.

cybertk avatar cybertk commented on June 2, 2024

Correct.

from abao.

cybertk avatar cybertk commented on June 2, 2024

@agrover8 I have an idea for your condition, test multiple test cases for one case. You can write multiple hooks, then run Abao multiple times with different hook.

Such as,

$ abao origin_new.raml https://test.com/ssvui --hookfiles=hook1.coffee

$ abao origin_new.raml https://test.com/ssvui --hookfiles=hook2.coffee

$ abao origin_new.raml https://test.com/ssvui --hookfiles=hook3.coffee

from abao.

cybertk avatar cybertk commented on June 2, 2024

You can open a feature request either, we will implement it in future.

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk
Can we pass request data from external file to hook file, like in RAML we can !include example.sample?
Instead of passing request data in hook file I want to pass reference of the external file.

from abao.

cybertk avatar cybertk commented on June 2, 2024

Yes, you can. Hook file is just a normal javascript/coffeescript source file, you can do whatever you want.

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk
There are some instances where we need to pass the response data from one resource to request data, query parameters, uriParameters to other resource, is that possible in ABAO?

from abao.

cybertk avatar cybertk commented on June 2, 2024

Yes. Do whatever javascript can do

from abao.

jekhardt avatar jekhardt commented on June 2, 2024

Filed #35 for multi test case.

I had some working example going of parameter passing using some global context variable to define things.

Something roughly like...

context = {}

after < test 1 > ...
context.example.id = test.response.body.example.id

before < test 2 > ...
test.request.query.id = context.example.id

@agrover8 is your hook file working now?

from abao.

agrover8 avatar agrover8 commented on June 2, 2024

@cybertk @jekhardt Yes, hook file is working now. I am closing this issue.

from abao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.