Question

In our client / server application, the server side is exposed by a collection of web services. The client interacts with what we call an Application Context to make calls to the server. I'd like to be able to mock the Application Context during acceptance testing so as to isolate the testing to just the client, rather than letting the tests flow all the way from client to server to database and having to set up the database with the right data for each test that we want to run.

Is this possible? Or should I be taking a different approach?

Was it helpful?

Solution

White runs using Microsoft UI Automation, which looks at any supported GUI. It doesn't worry about the code underneath at all, and you can't interact with that code in the same way you'd be able to with a unit test.

Typically you'd start up your application via its .exe, then use White to automate it. To start it up with just the client, you'd need to cause the process itself to start with the mocked-out application context. That would mean compiling the .exe accordingly, or having two different executables, one of which configures your packages correctly and one of which doesn't.

Without the database, you're not really running an acceptance test - one which verifies that the code is in a good state for acceptance into production. So I wouldn't worry about mocking out the database.

I would take one of these approaches:

  • Recreate the database for each test run, populating it with an appropriate context if required

  • Tag the data generated by the test with the date-time so that you can tell it apart from normal data

  • Make a mock version of your server which responds with fixed responses for the requests, and direct the application to use that instead (maybe with just a command line arg). Please note that this still won't verify that everything works with the database. It may be appropriate if you just want to show error handling, or if another team is going to be responsible for producing the service.

Hope these ideas help and provide options, anyway!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top