Start a new topic

Simpler writing unit/system tests with Virto

As an developer i want to write simple unit tests/system tests to verify custom logic in my custom virto modules which not uses virtos rest api.

It's time consuming and complicated to mock virto commerce (but possible ).

I want to run unit(system) tests with a real virto database.

I still belive it would be quicker to start this kind of unit test than starting iis.


I started with unity registrations

            UnityContainer container = new UnityContainer();

            (new VirtoCommerce.CoreModule.Web.Module(container)).Initialize();

            (new VirtoCommerce.CatalogModule.Web.Module(container)).Initialize();

            (new VirtoCommerce.CartModule.Web.Module(container)).Initialize();


but in VirtoCommerce.Platform.Web.Startup.InitializePlatform unit registration is mixed with web 




Could you provide which kind of functionality of your module you wants to cover by tests or better send link to code? Because you mention "Unit test" but looking to your mocks it seems that you are writing an "integration test".  For "integration" tests should be different test environment and approaches, and you do not need mocked  all code depended VC modules and platform services. 

Yes Im looking for writing systems test with ms tests.

The benefits i wants is:

* Less Virto mocking for simpler writing tests.

* Quicker running my customer code by remove the need to start web when developing in vs in tdd way.


We have end to end tests but then its harder to localize the error.



I have attached a simple picture of an test I Call our CartController which is calling virtos cartbuilder and the moq insanity starts and then we have to moq dynamicproperties etc etc.


some unity registrations capture2.png which forces us to add dll references to virtis web projects to reach unity registrations the platform has mixed unit registrations with web code so Capture3.png.


please contact me at pierre.setteskog@wipcore.se we have also contacted Alexander



Capture3.PNG
(48.4 KB)
Capture2.PNG
(57.8 KB)
Capture.PNG
(40.7 KB)
Login or Signup to post a comment