spock

How do I get SonarQube to count spock/groovy unit tests?

孤街浪徒 提交于 2019-12-11 06:25:35
问题 I am trying to configure SonarQube to report an accurate count of the unit test cases in my repository, currently it is only showing the java jUnit test cases. SonarQube reports the java jUnit test count as well as the overall coverage from jacoco which includes both java and groovy coverage. How do I get SonarQube to recognize the groovy/spock unit tests in the overall count? SonarQube 7.7 (I see the issue on 7.4 as well) I am not sure if there is a specific sonar property I need to set in

Spock: mocked class's method is not being matched

人盡茶涼 提交于 2019-12-11 04:48:01
问题 I was able to get a passing test for the dumbed down version of my code (thanks to cgrim! Spock: method not recognized as an invocation), but with the real code it won't work unless the getAssetIdBatch returns something that is non-null. I can't figure out why my interactions aren't being implemented. Below, you can see three attempts to get getAssetIdBatch to return the map1 sample. Here's a dumbed down version of the code: class VmExportTaskSplitter implements TaskSplitter<Export> { @Inject

Is it possible to randomize the order in which Spock tests are executed?

亡梦爱人 提交于 2019-12-11 04:09:42
问题 it seems that spock tests are executed in the same order, most of the time. Is it possible to set some option to execute them in a random order? Update: as tim_yates commented "tests should be isolated, and order shouldn't matter", I think I should explain why I would like to have this feature... We had a code retreat where we tried to just tried to turn the tests green. So we implemented a state in the class under test which then would be used to return the corerct result for all tests. To

Spring boot and Spock integration test

白昼怎懂夜的黑 提交于 2019-12-11 03:45:10
问题 I am new to Spring boot and while testing the REST endpoint using SPOCK , came across with the question #24405727 I have tried the exact configuration but getting the below exception java.lang.IllegalStateException: The WebApplicationContext for test context [TestContext@21a722ef testClass = HelloControllerSpec, testInstance = com.hello.HelloControllerSpec@63e68a2b, testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@3479404a testClass =

Spock behaving weirdly

限于喜欢 提交于 2019-12-11 02:48:09
问题 RunWith(PowerMockRunner.class) @PrepareForTest(StaticCallInvoke.class) @ContextConfiguration(locations = "file:test/spring/Beans.xml") class TestClass extends Specification{ @Test def "Testing staticMocking"() { setup: def someObject=new SomeObject(); someObject.someValue=100 PowerMockito.mockStatic(StaticCallInvoke.class) when: ClassUnderTest.executeSomething(someObject) then: someObject.someValue=110 /*Wrong Value,It says assertion failed. Thats absolutely fine becuase the value should be

Runtime Exception Mocking groovy.sql in Spock

我的未来我决定 提交于 2019-12-11 02:19:39
问题 I've scoured around StackOverflow and Google for a while trying to find the right configuration/syntax for being able to run this code in a Spock Specification: Sql mockSql = Mock() However when I run the unit test, I get a nasty exception thrown in my face by CGLIB: java.lang.IllegalAccessError: tried to access method groovy.sql.Sql.<init>()V from class groovy.sql.Sql$$EnhancerByCGLIB$$d0b7cd7f at org.spockframework.mock.runtime.MockInstantiator.instantiate(MockInstantiator.java:33) at org

Grails 2.2.3 Can't Find Spock on Classpath

大憨熊 提交于 2019-12-11 01:30:40
问题 I just added spock to a Grails 2.2.3 project I added the following dependency to Buildonfig.groovy : plugins { test(":spock:0.7") } Then created my Specification class, "test/unit/LocationSpec.groovy : import grails.test.mixin.* import org.junit.* import spock.lang.* /** * See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions */ @TestFor(Location) class LocationSpec extends Specification { def setup() { } def cleanup() { } def "compare"() { when: def

Multiple assignments in the where clause of a spock test?

爷,独闯天下 提交于 2019-12-10 17:19:52
问题 I'm using the Spock framework for testing, and I have a question regarding multivaraible assignment in a where clause. I have the following test case: def "sending a message delegates to message sender"() { when: sendMessage(x,y) then: 1 * messageSender.send(x,y) where: x << 1 y << 2 } I want to replace the multiple variable assignments in the where clause with a single assignment operation. I tried: where: [x,y] << [1,2] but got a MissingMethod exception. I assume this is because the

Grails 2.3 IntegrationSpec cannot be transactional false

心不动则不痛 提交于 2019-12-10 17:07:56
问题 I upgrade to Grails 2.3 recently and try to migrate all old tests to spock integration test. But it fails at cleanup because my test is non-transactional. The Grails doc says test can be non-transactional, but we need to handle it manually, but it seems not quite right here. as I am getting this error in every integration test extending IntegrationSpec java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active at grails.test.spock.IntegrationSpec.cleanup

How can I get WebDriver to dismiss a Firefox Security Alert?

江枫思渺然 提交于 2019-12-10 16:23:41
问题 I am writing a test script using spock, geb, and WebDriver. The script submits a form on an insecure page. The page submits to a secure HTTPS URL. Firefox shows a warning for this, specifcally: This causes the following error: org.openqa.selenium.UnhandledAlertException: Modal dialog present Build info: version: '2.23.0', revision: '17137', time: '2012-06-07 09:08:12' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33' Driver info: driver