Mocking webservice ... sometimes

I am trying to write acceptance testing for an existing application.

I had a problem though when calling a web service that tells us if the person, in short, is in the office or not, what hours and who is the backup.

Most tests actually call a web service fine ... yes, ideally it shouldn't be, but creating inputs and outputs for many times when this service is called is a HUGE task.

What I would like to do is make Mock generate the default result regardless of the input, but it should be generated by the code based on the parameters, because there is temporary data during the call and the result.

And, if I choose to set up a different result on several selected inputs of the method when testing according to the test scenario.

Basically, by default, people are in the office. If I do not set up the layout so that they are not.

Can I do this with Moq? And How?

I'm new to writing tests and ridicule, so if you need more clarification, ask.

+3
source share
3 answers

You may be able to do this with Moq or another dynamic Mock, but it doesn't seem like it would be a good idea.

, , - - , ​​ , -, . Fake Mock.

, Fake - .

A Mock, , , , , . , .

, , , - -, , . , AutoFixture.

+2

[ : Mock (http://martinfowler.com/articles/mocksArentStubs.html]. , , , , ( , ), (.. , , mock object, , ...). unit test, , . , - ( , , , ).

+1

- sourceForge. .

http://sourceforge.net/projects/easymocker

Mocker Web Service is an easy-to-use web service based SOAP web utility. This utility is very useful in the SOA development environment during the unit test, component integration test, and non-functional requirements testing.

+1
source

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


All Articles