How to check asynchronous website activity between two users

We are trying to write BDD tests using Jasmine, and for general use we have to access:

User A: Does some action
User B: Gets notified after xx ms that the action has happened asynchronously (either via WebPush or polling)
User B: Responds to user A action
User A: Receives B response

I am trying to build an automated test for this scenario. Our current tool of choice is Jasmine, but we are flexible at the moment. How can you handle multiple logins at the same time, especially where there is some delay between responses?

+3


source to share


1 answer


A naive way to do this is to simply poll for each action and move the script right after that action has been detected, with timeouts that fail the test if it takes too long.

In any language that allows multi-threaded execution, you can create a Waiter template that waits for an event and then passes execution back to the test when that event is detected. I have a C # example here and a Java example here .

Javascript does not allow multithreading, but it can be spoofed .

However, I think your biggest problem is that with two inputs, you essentially got two tabs or windows or tabs or applications, and yes, that would be difficult to manage. You could do this with something that interacts with windows, not the browser (my C # example is from an automation tool that does this), but that would mean adopting a whole different technical stack for automated scripting.

You can get around this by splitting your script into parts:

Considering that users A and B launch the application
When user A performs some action Then user B should be notified.

For B, use a fake version of the app; take out everything from service. Then you can check that B is notified via the service API. You can even just write what B gets to a text file or something similar. It doesn't have to be real B.



Considering users A and B launch the application
When user B receives a notification from user A
Then user B has to respond.

Given that users A and B launch the application
When user B responds Then user A should be notified.

For these purposes, we now truncate the application for A, notifying it as A through the API in the first and checking the notification from B in the second.

A given user A is waiting for user B to respond When A receives a response from user B Then A must (do what he normally would when he received a response).

And we'll go back to B again, injecting the B response into the API, taking the journey to a full circle.

In each case, we still check if the interaction with the service is working; we just don't do it all at the same time. This should still provide ample confidence that all is well. This requires a few more scripts.

Please talk to this business and use the language they use when describing what they do, not A and B notifications and responses like me.

+1


source







All Articles