How do you validate a view in MVVM?

I saw several articles about unit test models in MVVM and how the tests themselves are consumers of view models, testing the functionality of the viewModel model and model. However, I don’t care how I test the views (UIs) to make sure they are connected correctly to my view models. I don’t want to write a test that, for example, presses a button to make sure something is written in db, as this effectively checks my virtual machine, which I have already done.

For example, I would like to write a test to make sure that the button is connected to a specific command. Therefore, do not let anyone go and delete the button command, making it no longer functional.

Is it possible? thanks.

+3
source share
3 answers

But what if someone (hopefully a designer) wants to change Buttonto MenuItem? Your test will break and you will have to fix it. One of the main points of MVVM is that designers can really freely organize and rearrange the interface as they like, without requiring too much back and forth with the developers. Writing unit tests against the user interface will invalidate this.

I kind of play Devil's lawyer here. I'm not saying that the user interface is completely useless and never takes place in any codebase. I say that income is declining and that you can trade one problem for another.

""., , , . , . , API WPF, , , .

+2

, - Telerik (Art of test), . http://www.artoftest.com/products/webaii.aspx , Silverlight, WPF. , .

0

, , . , - , , , , ). , , . , , , , , : http://blog.zuehlke.com/en/mvvm-and-unit-testing/

0

Source: https://habr.com/ru/post/1714780/


All Articles