Any better alternative to Groovy for Java integrat

2019-05-08 19:04发布

I am planning to test my Java-based web application using its programming interfaces. To this aim, I intend to call my session beans using their RMI/WebService interfaces and check if their supported services are correct or not. To do this, I need a scripting language to:

  • Call my RMI/WebService interfaces
  • Execute SQL statements (e.g. for cleaning the DB at first)
  • Have a simple flow control (loops, conditions, etc. )
  • Be easy to understand. I may ask my non-programmer staff to write test scripts

I am planning to use Groovy to this aim. Is there any better suggestion or alternative for Groovy?

Edit 1

Other introduced alternatives to Groovy mentioned in answers are JRuby and RSpec. Is there any comparison for them on the web?

2条回答
趁早两清
2楼-- · 2019-05-08 19:17

I would recommend RSpec with JRUby.

RSpec is very clear, descriptive and easy to understand, even non-programmers can use it. With JRuby you can do pretty much everything you can do with Java.

So RSpec with JRuby sounds like a good match for your requirements.

For an example see http://patshaughnessy.net/2009/6/25/taming-the-beast-using-jruby-and-rspec-to-test-a-j2ee-application

查看更多
Juvenile、少年°
3楼-- · 2019-05-08 19:26

I think Groovy is the best that you can use for your tests. Groovy integration with Java is seamless, thus calling methods, libraries, and stuff like that usually run smooth.

Also companies which are starting to use Groovy usually start using it for tests, and later use it in production code.

As @tim_yates said, Spock is a Groovy framework for testing and a great one. You can also use JUnit/EasyMock/TestNG/Whatever without problems, and Groovy itself comes with the GroovyTestCase (based on JUnit) which gets the job done.

Groovy also enables you to write cool DSLs, which help you to achieve a programming language for non-programmers, as you said you need.

SQL support in Groovy is also simple. You can use groovy.sql package classes and get started really fast with it, or you can go for JPA if you want.

查看更多
登录 后发表回答