03-04-2019 10:17 AM
I plan to unit test the webscripts that had Java as controllers. I have found two approaches.
1) Go along the lines of bootstrap code HelloWorldWebScriptControllerTest.java
2) Follow https://github.com/Alfresco/alfresco-remote-api
. Here, the test classes extend org.alfresco.repo.web.scripts.BaseWebScriptTest
.
For the second approach, I tried adding the following dependency, but cannot find this BaseWebScriptTest.
<!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-remote-api --> <dependency> <groupId>org.alfresco</groupId> <artifactId>alfresco-remote-api</artifactId> <version>5.2.b-EA</version> </dependency>
I tried adding <classifier>tests</classifier>
to the above dependency as well. But, cannot find this class.
How can this issue be resolved? Also, which approach is suggested?
03-05-2019 01:21 AM
In the second approach you are trying to add EA version,which does not exist in the specified url.
You can use another version.
Check by your self on below URL.
03-05-2019 01:53 AM
I have taken the latest one as well. But, the BaseWebScriptTest is missing. I was wondering if my approach to alfresco-remote-api is correct.
Also, if I follow the first method, I need to mock lot of services as well. How should I mock ServiceRegistry or NodeService?
03-13-2024 05:32 AM
However, in this way you would always need an active container. There are other quicker and easier ways to test a controller. You could simply add the alfresco-tests library into your sdk, write a test and run it without needing an active ACS. Here you will find the details https://alfresco-tests.vige.it
Explore our Alfresco products with the links below. Use labels to filter content by product module.