In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to make groovy grammar in spock. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Introduction
When using the spock test framework, the following test code often appears:
/ / Test method def "test plus 1" () {given: "prepare data" def a = 1 def b = 2 when: "Test method" def c = calculateService.plus (a, b) then: "check result" c = = 4-1}
Many people treat it as a fixed format, especially those like me who started groovy and spock from java in a few days, and hardly delve into what grammar this is.
In fact, some groovy-specific syntax formats are used in the spock framework, which are not common in Java, as follows:
Labeled statements label statement
Any statement can be associated with a label. Labels do not impact the semantics of the code and can be used to make the code easier to read like in the following example:
Any statement can be associated with a tag, which not only does not change the semantics, but also makes the statement more readable, as follows:
Given: def x = 1 def y = 2when: def z = x+ythen: assert z = = 3
In fact, there is also a tag statement in java, with the following code:
For (int iTuno Bandi)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.