I had submitted an idea regarding functional testing on Liferay and also ended up with it. So what to do about such a large topic in 24 hours? Well, first I googled the topic. Everyone including Lifreay itself is using Selenium, but I wanted something lighter, smaller and not dependent on external browser.
Initially I installed Canoo Webtest and started playing with it, but it felt a bit clunky and old fashioned with all the xml-files and rather weird runtime build on top of Ant. I had already decided to use Groovy for the tests since Canoo also supports it, but the documentation just wasn't there and the syntax was too ant-line also.
I've been toying with Grails Functional Testing Plugin recently and I've really enjoyed the simplicity and elegance of it. So I decided, what the hell, I have still almost half of our Fedex Day left so I rolled up my sleeves and started to port the grails plugin over to my Liferay-project.
After a while I had a stripped-down version of the grails plugin with all references to grails removed. Then I proceeded to make a very simple ant-script that compiles the groovy-files (we already have groovy-all.jar in our liferay project template so this was easy to do). Then I set up a directory called "funtional-tests" in the Liferay Plugins-SDK project and created the simplest possible test I could think of:
class SimpleTest extends functionaltestplugin.FunctionalTestCase { void testHelloWorld() { get('http://localhost:8080/') assertContentContains 'Hello World' } }
Naturally it took some figuring out to get rid of weird errors, but soon it was working! Call me a nerd, but I think that's pretty cool.
Future plans
This is of course just a beginning. One big question is how to sandbox the functional test or the environment itself. Luckily I have a colleague here at Ambientia who is working on a small tool that can create pages, portlets and other data based on a simple xml-format. Using that we can setup and sandboxed environment where portlets can be tested functionally without having to ruin the actual portal you're building.
Also I'm thinking of trying to run Lifreay in Jetty embedded. This would make it possible (in theory at least) to control the whole environment while running the functional tests. I will try this anyway and report success or failure.
Another issue is controlling the state of the portlets themselves. What if you have a complex portlet done using Liferay's Service Builder that has it's own database and you want to run functional tests on it? I'm thinking maybe the edit-mode of portlets might help here. You might set up things like "create test data" and "destroy database" as simple buttons in the edit-mode and these wouldn't be too hard to call from the functional test. It could look something like this:
class ComplexTest extends functionaltestplugin.FunctionalTestCase { void testEditMode() { get('http://localhost:8080/home/portletXTestPage') click 'edit portlet x' click 'create test data' //run the actual test } }
There is still lots to be done, but I'm quite optimistic about this.
Hello,
ReplyDeleteThe Article on Liferay functional testing is informative..It gives detailed information about functional testing. Thanks for Sharing the information about the Help the suits write functional tests for Angular apps For More information check the detail on Functional testing check, Mobile App Testing
The Article on Mobile testing Services Map is awesome nice pie chart description, thanks for sharing the information about it.Mobile app testing Services and load testing services.
ReplyDeleteReally Happy to say your post is very interesting. Keep sharing your information regularly for my future reference. Thanks Again.
ReplyDeleteTop Big Data Companies
Top Data Analytics Companies
Top text analytics Companies
Top Software testing companies
Top Machine Learning Companies
Top Mobile App Development Companies