sapmentors / sitregcapm

SITreg implemented in the SAP Cloud Application Programming Model
Apache License 2.0
12 stars 13 forks source link

Integration tests #13

Open gregorwolf opened 5 years ago

gregorwolf commented 5 years ago

Hello @balbinosoares @NabheetCloud @mattiastrr @lechnerc77,

thank you for all your contributions. Great to see them flowing in.

In SITreg I've created integration tests calling the OData API using users with the corresponding role assigned. I would like to follow this approach in CAPM too. What is the standard tool to run API tests in a NodeJS environment? Does SAP already posted some best practice?

In the next step we would also need to setup local authentication + authorizations to be able to test the different user roles.

Best regards Gregor

lechnerc77 commented 5 years ago

Hi Gregor,

I think Supertest (https://www.npmjs.com/package/supertest) might be an option for API tests in node.js

I am not aware of any best practises by SAP in CAPM context.

BR Christian

balbinosoares commented 5 years ago

There is mocha and chai, but I never used... there is a combination of mocha and supertest too...

lechnerc77 commented 5 years ago

I use mocha and chai for unit tests, I do not really see a way how to use them for integration tests that Gregor targets. I would say mocha and supertest might be worth a try, although I did not yet use supertest

balbinosoares commented 5 years ago

I also think we can use mocha and supertest

NabheetCloud commented 5 years ago

Mocha and Supertest makes sense. Infact i was checking your existing app you have used Jasmine to test XSC app. Jasmine can also be used with NodeJS apps. I think we shall also check with @qmacro for his recommendations in this area and what SAP recommends.

PS: Mocha/Supertest looks okay.

gregorwolf commented 5 years ago

What's about https://jestjs.io/ ?

chgeo commented 5 years ago

Jest is what is used by here at SAP to test the Node.js parts of CAPM. Reason not to use Mocha + Chai + Istanbul + Sinon + Supertest is not wanting to manage the dependency issues between all our dev dependencies.

gregorwolf commented 5 years ago

Thank you @chgeo for jumping in. Is it feasible to use Jest to call the OData API's locally and in a CI tool? Are there any public examples for that? Or could you contribute them ;-)?

chgeo commented 5 years ago

As discussed.. we are working on guidelines.. will publish as soon as they are ready. Stay tuned :)

gregorwolf commented 5 years ago

An inspiration for testing can be found in the openSAP HANA7 Course Exercise Materials

gregorwolf commented 5 years ago

With #23 we have a first working test case. Feel free to create test cases based on the tests from the old SITreg backend

gregorwolf commented 4 years ago

With #46 I've added API tests with Jasmine. Unfortunately the usedrequest library is deprecated. So this must still be migrated to axios.