I'm starting to implement Integration & UI tests in my application using Mocha and Chai.
Let suppose I give to my users the possibility to register to my application with some credentials so that it can access a private part of my app.
I have decided to implement my testflow so that mocha can test the whole story that the user can experience while using my application.
Example:
- The user, since he's not logged, cannot see the private informations and receive an error message.
- The user registers with new credentials and receives a token
- The user is now able to access the private informations.
- The user logout from the application using the token from step 2
- The user is able to login again with the same credentials used in step 2
- The user changes the password of his account
- The user is able to login again with his new password changed in step 6
- The user is able to delete his account
Of course each step is a different API call that I want to test.
As you can see the testflow is very big and intertwined since every step needs some information from the previous one to work (the logout needs to know the token, the login needs to know the credentials and so on)
I can achieve this result in mocha putting everything in a test suite called "Auth Testflow" and then, inside, a lot of sub-suites that represents each one a different action (register, login, logout, ...). In each sub-suite I have all the test that needs to run for each action.
The file containing the test becomes immediately very large (600 lines of code) and very unmanageable.
I searched the internet for solutions to split each step in a different file and then running them all together but I couldn't find a solution (This is a previous question that I asked regarding this problem )
Since I cannot find any information about this topic I started to think that maybe this is not the best way to test APIs and there is a better method out there.
The question is: How do you manage to test this type of scenarios in your applications ?
Aucun commentaire:
Enregistrer un commentaire