on 2017 Jan 10 9:16 PM
We have extended ycommerceservices to create our custom OCC services.
The newly created extension is - "mycommerceservices". The extension has "testsrc" folder under which we usually wrote unit and integration tests.
However, when using modulegen and using ycommerceservices template, another extension which is testcommerceservices is also generated. So what is the significance of this extension?
What is the best approach to wrote unit and integration tests for OCC based services?
Thanks.
ycommercewebservicestest initially were "invasive" - they loaded sample data to master tenant instead of junit tenant.
They also worked outside of platform test mechanism and calling ant:alltests did not executed them. You needed to st platform and execute tests separately on running platform. You can find more on that on https://wiki.hybris.com/display/release5/ycommercewebservicestest+Extension
Starting from version 6.1 ycommercewebservicestests were updated and no longer load data to master tenant. They also can be executed with other platform tests. https://help.hybris.com/6.1.0/hcd/8c921d1d86691014974694521521b7e6.html
They remained a separate extension because of the flexible nature of OCC. Many addons may redefine endpoints in OCC and change their behavior but there is no mechanism to overwrite tests.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the ycommercewebservicestests uses groovy for writing the unit tests. I would rarther prefer using /testsrc within my custom webservices framework instead of using the separate extension for all the unit test cases as it would mean either follow the groovy way of writing unit tests or rewrite the existing unit tests in java spring.
My understanding for unit testing of webservices is that we will write tests for > service layer, facade layer and DAO (if any). For rest controllers which are no different from storefront standard controllers, it won't add much value.
In the previous post I tried to explain why ycommercewebservicestest is separate extension. The recommended way of writing tests is to do it in /testsrc.
If your controllers do not have any logic but just invoke facade then it may be pointless to write tests for them. On the other hand if controller has complex logic I would recommend writing a test for it.
I agree with what you said. One last question on JUNIT TENANT. Currently If i write an integration test by extending ServiceLayerTransactionalTest, I can execute it either from ee or ant yunitall. So where does JUNIT tenant come into picture? We are writing everything as OCC service and writing unit and integration tests for facades and controllers. So if i execute it do i need to initialize my junit tenant to run the test?
If your tests extend ServiceLayerTransactionalTest and have IntegrationTest annotation then they are using JUNIT tenant. You need to initialize it by running ant yunitinit - but its required only once (unless you are changing models). When you wite your tests you want to run them in isolation - you don't want some external data to affect your tests. And that is what junit tenant gives you. You can create a customer without worrying that it may already exist in the system etc. You can also easily just remove it as its needed only for tests.
User | Count |
---|---|
24 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.