Skip to main content

2 posts tagged with "junit"

View All Tags

Testing plugins with Ivy using Powermock

· 2 min read
Java Developer and Software Engineer

Recently, liferay-plugins SDK (and also its EE version) switched to using Ivy to manage some of the dependencies. Even when there are still static dependencies taken from defined portal -- Ivy dependencies are added to the lib/ext and ROOT/WEB-INF/lib ones, see build-common.xml -- this makes adding dependencies into plugins so much easier and cleaner.

Creating unit tests in core Liferay sources

· 3 min read
Java Developer and Software Engineer

Liferay has been catching up lately on the tests coverage. Many improvements have been made in the trunk located in liferay-portal / master branch on GitHub and since I've been fixing some things recently, I've included unit test for the changed class as well.

Quick start how-to:

  1. read Liferay testing documentation to get the basic picture,
  2. create your unit test in portal-impl/test/unit/.../<your_class>Test.java,
  3. create test methods as usual with JUnit 4.x,
  4. run the test and see results:
    • cd portal-impl,
    • ant test-class -Dclass=CustomJspRegistryImplTest,
    • note that only the name of the class is used, not the full name including package.

Testing just a single class at a time seems to be necessary, executing ant test-unit to run all existing unit tests seems to be time consuming (from minutes to tens of minutes).