Any better alternative to Groovy for Java integration testing? [closed]

有些话、适合烂在心里 提交于 2019-12-07 10:55:56

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/13775420/any-better-alternative-to-groovy-for-java-integration-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!