How to Test View in Winforms

390 views Asked by At

I have a scenerio where I have to get some data from the DB and display it in a Grid View in a Win forms app. I have written a unit test for Presenter mocking my repository and view. The test checks that the presenter calls the GetData() method of the repository and then calls the Bind(data) method of the view.

I have also another Integration test for the repository that verifies that if there is some data in the DB it is returned by the repository.

Now comes the part of testing my view. I can think of no way to test my form and check if it indeed binds data to the Grid view.

My question is that is there no way to test views in Winforms and will I always have to rely on manual testing for that?

1

There are 1 answers

1
Sergey Berezovskiy On BEST ANSWER

I suggest you to test view and database only in acceptance tests. And you should understand, that this kind of tests very brittle and take lot of efforts to implement and support. Of course, manual UI testing is not very good idea - you should use some UI test automation tool like: