Messagebox and Unit testing

后端 未结 4 1677
再見小時候
再見小時候 2020-12-28 21:37

I\'m trying to find the best way to uncouple messageboxes from my logic so I can properly unittest it. Now I was wondering if it would be enough if I just made a seperate he

4条回答
  •  情深已故
    2020-12-28 22:07

    Ideally, you want the code your testing with Unit Tests to be logic and not UI. Therefore, the logic your testing shouldn't really be displaying a message box. If you are wanting to test the UI, then I would suggest Coded UI Tests.

    Judging by your question, I would imagine your code shouldn't really be using a MessageBox. Perhaps instead consider using a callback or arbitrary Action, or the approaches mentioned by Luke McGregor and Sergey V.

提交回复
热议问题