Setup for Local Testing in Eclipse
Wouldn’t it be nice to get instant feedback if your application still works after each change? Having the correct setup of your development environment, this can be easily achieved. With local testing, you get instant feedback after each change and can execute your unit test and your local test page before committing your changes to the repository. There are some pitfalls regarding local testing in Eclipse. This post provides an overview and links for more information.
- You can either use Tomcat or the WebAppPreview for local testing.
- Pitfall 1: SAPUI5 Version used for local testing is too old.
- By default, the runtime libraries from the Eclipse plugins are used. (You can find out their versions under Preferences/SAPUI5). There is, however, a different solution: Either you update your Eclipse installation, which also automatically updates SAPUI5, or you configure the resource servlet. For more information about the configuration of the resource servlet, see:
- http://help.sap.com/saphelp_nw74/helpdata/en/61/ee9ed2369f4764a6d713abcf73afc1/content.htm?frameset=/en/91/f2412f6f4d1014b6dd926db0e91070/frameset.htm
- Pitfall 2: Tomcat caches your files and does not consider changes
- Enable Serve modules without publishing in the Tomcat web.xml. Otherwise, when you change a web resource in META-INF/resources in a library module, this change will not directly be visible in the running application after reloading the current page in the browser.
- Pitfall 3: Browser caches your files and does not consider changes
- You could adjust the browser settings. For Chrome there is a setting in the Chrome developer tools, which disables caching while the developer tool is open. For more information, see: https://developers.google.com/chrome-developer-tools/docs/settings
- A better alternative is to disable caching in the resource servlet. SAPUI5 provides a ResourceServletweb.xml. To disable caching, open the web.xml file located in the <WebContent folder name>/WEB-INFcom.sap.ui5.resource and change the parameter com.sap.ui5.resource.DEV_MODE to true.
This blog post is part of a series, like the following blog post to stay tuned and get updates about more topics around software engineering with SAPUI5 and JavaScript:
http://scn.sap.com/community/developer-center/front-end/blog/2013/12/12/engineering-in-javascript
I want to thank Klaus for his personal dedication in driving the topic and collecting best practices.