spock

Geb exception when running tests in maven

本秂侑毒 提交于 2019-12-12 02:52:53
问题 I get this exception when I run my tests from command line with maven. My command: mvn -Dtest=specs.full.* -Dtestsystem=Win7/IE test On my local machine, everything works fine. But when I run the tests on our server, where jenkins is installed, I get following exception: java.lang.VerifyError: (class: specs/full/ReadCheckMenuLinks, method: super$8$$spock_feature_3_1 signature: ()V) Illegal use of nonvirtual function call at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class

Highlighting certains words in Eclipse

纵饮孤独 提交于 2019-12-12 02:29:13
问题 I am writing spock tests in Groovy / Grails in Eclipse. These use key words such as setup: the: and when: . I'd like to be able to add some syntax highlighting to these words. Is this possible? Thanks. 回答1: Please try the Spock Eclipse plugin: http://marketplace.eclipse.org/content/spock-plugin#.Uht-2Lw26KQ I think it will do what you require. 回答2: XText looks really cool, with extensive documentation and support. Is it too complex for what you need? Either that, or if you have knowledge and

How to create instance of WCMUsePojo in my Prosper spec?

孤人 提交于 2019-12-12 01:57:37
问题 I have a functioning WCMUsePojo Groovy class which is called from a sightly html component. I am trying to create an instance of my WCMUsePojo class for testing based on the content from the Prosper setup method. It's basically the same type of question as How can I create an instance of WCMUsePojo in a servlet for a specific page? But I don't see it answered and this is specifically about how to unit test methods in WCMUsePojo classes within the Prosper framework. Is there a Java or Groovy

Why is this method returning null even though the underlying controller is mocked using Spocks' Mock()?

自作多情 提交于 2019-12-12 01:28:41
问题 import grails.plugin.spock.* class EventControllerSpec extends ControllerSpec { def "Creating a breadcrumb from an event"() { given: "I have a named event" def eventController = Mock(EventController) def event = Mock(Event) event.title >> 'Space-Journey with Sprock and the Crew' event.title == 'Space-Journey with Sprock and the Crew' when: "I create a breadcrumb from it" def eventCrumb = eventController.createCrumb("Event", "show", "1", event.title) /* private Map createCrumb (String

Configuring Geb and Spock on Jenkins (Grails)

陌路散爱 提交于 2019-12-11 20:19:33
问题 I cannot use port 8080 for my testing. When I set the port to another open port (8090) Geb-Spock tests work fine, but only while running locally on IntelliJ. However, if I try and run a Jenkins build, I come out empty handed. I am pretty certain the problem has something to do with my GebConfig.groovy. Note: I am using xvfb to aid the browser, and I am fairly certain it is configured correctly as it is producing results when configured to 8080. Running on port 8090... Running on port 8080...

executeUpdate query not working on grails spock test

依然范特西╮ 提交于 2019-12-11 20:12:21
问题 Now willing to do integration test as below but problem is that MerchantTier.executeUpdate('update MerchantTier..........'), here update does not working but if I make update with def merchant = MerchantTier.get(params.id.toLong()) merchant.setValue(merchantTierVal) instead of execute update it works Is there is any prolem with executeUpdate Query? def merchantTier def setup() { merchantTier = new MerchantTier( startTier: tier, endTier: tier, value: 2.02).save(flush: true) } void "for given

Upgrading Spock unit tests from Grails 1.3.9 to Grails 2.3.9. But edit() test is failing

倖福魔咒の 提交于 2019-12-11 18:08:06
问题 I am updating unit tests in a Grails project. We were originally using version 1.3.9 and now we are updating to version 2.3.9. I am using Spock. I keep getting this error: results: junit.framework.AssertionFailedError: Condition not satisfied: controller.edit() == [filterCategoryInstance: filterCategoryInstance] | | | | | null false John com.xxxxxx.xxxxx.FilterCategoryController@20574000 Here is the controller code: @Secured(["hasAnyRole('CM_ADMIN')"]) def edit() { def filterCategoryInstance

Spock Testing got NoClassDefFoundError: net/bytebuddy/TypeCache when Mocking RestTemplate

爱⌒轻易说出口 提交于 2019-12-11 17:48:04
问题 I am testing my DAO class which uses a custom RestTemplate that extends RestTemplate to do postForObject, but I am getting the below error even after I added byte-buddy dependency to pom.xml. This error seems happening on the call to Mock(). Can someone please let me know what I did wrong? NoClassDefFoundError: net/bytebuddy/TypeCache <dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> <version>1.3.16</version> <scope>test</scope> <!--also tried giving "runtime"

Selenium 4 Java的最佳测试框架

大兔子大兔子 提交于 2019-12-11 16:43:05
几十年来,Java一直是开发应用程序服务器端的首选编程语言。尽管JUnit一直在与开发人员一起帮助他们进行自动化的单元测试,但随着时间的推移和测试行业的发展,特别是伴随着自动化测试的兴起,已经开发了许多基于Java的开源框架,它们在验证和业务逻辑方面与JUnit有所不同。在这里,我将讨论用于使用Selenium WebDriver执行测试自动化的顶级Java测试框架,还将重点介绍这些顶级Java测试框架的优缺点和独到之处。 JUnit Junit是开发人员基于xUnit基础上开发的一个实用案例。其最初主要目的是使Java开发人员能够编写脚本并执行可重复的测试用例。它通常用于测试一小段代码。您还可以通过将JUnit与用于测试自动化的Selenium集成来执行网站的自动化测试。每当添加任何新代码需要发版时,都需要重新执行整个测试用例,并确保没有不影响原有功能。 有哪些先决条件? 该框架与Selenium WebDriver for Java高度兼容,因此,JUnit和Selenium WebDriver也是完全兼容的,作为某些先决条件,您需要 在工作项目中使用较新版本的JDK。 下载最新版本的JUnit并设置环境。 对面向对象的编程语言(Java)的应用程序开发有很好的使用经验。 使用JUnit的优缺点? JUnit有几个优点: 在受测试驱动的环境中工作的开发人员发现它非常有好处

Unit Testing a fluent API with mocking in Spock

邮差的信 提交于 2019-12-11 16:31:54
问题 Spock makes a strong distinction between a Stub and Mock. Use a stub when what to change want comes back from a class your class under test uses so that you can test another branch of an if statement. Use a mock, when you don't care what comes back your class under test just call another method of another class and you want to ensure you called that. It's very neat. However suppose you have a builder with a fluent API that makes people. You want to test a method that calls this Builder.