spock Questions
2
I have a grails application with version 2.3.1 and the next configuration in BuildConfig.groovy
dependencies {
...
..
.
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}
plugi...
1
Solved
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...
Subaxillary asked 10/6, 2014 at 18:54
4
Suppose I have multiple Geb/Spock tests that beings with logging in. For example:
@Stepwise
Class AddNewPictureSpec extends GebSpec {
def "User at login page"() {
given: "User beings from login ...
1
Solved
Spock only allows static variables to be accessed from where block.
Is there any workaround using which Instance variables can be used inside the where block ?
Blamable asked 28/3, 2014 at 7:59
3
I have an existing Java project set up in Intellij 12 and am attempting to add some Groovy classes to it. I've started with attempting to add a simple Spock class for testing purposes, but when I r...
Bryner asked 21/11, 2013 at 11:47
1
Solved
Is there any way to mock a file for unit testing in Grails?
I need to test file size and file type and it would help if I could mock these.
Any link to a resource would help.
1
Solved
Need to get TestNG to run my Spock Tests as TestNG is used throughout the rest of the system.
Since TestNG supports running JUnit tests, I tried this:
<!DOCTYPE suite SYSTEM "http://testng.org/...
Caudal asked 25/3, 2014 at 11:51
1
Solved
In our Spock tests we want to check if the correct path in our software is selected. But we do not want to test the function of the methods which are called (this is done in separate tests)
def "T...
1
Solved
I'm struggling to understand something about Spock interactions in a Groovy unit test.
I have the following types:
public interface Bar {
public String getMessage();
}
public class Foo {
priva...
Philis asked 6/3, 2014 at 5:38
4
I have some code written in Java that uses Generics. This is a simple version:
// In Java
public interface Testable {
void test();
}
public class TestableImpl implements Testable {
@Override
p...
1
Solved
The following example code:
class MySpec extends spock.lang.Specification {
def "My test"(int b) {
given:
def a = 1
expect:
b > a
where:
b << 2..4
}
}
throws the following com...
1
Solved
Here is my test class:
import grails.test.mixin.*
import spock.lang.Specification
import spock.lang.Unroll
import spock.lang.*
import groovy.util.logging.Slf4j
@Slf4j
@Mock([PromoRule, PromoCode,...
Zo asked 15/1, 2014 at 22:1
2
Solved
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-transa...
Trapezium asked 5/12, 2013 at 1:59
1
Solved
Groovy generates getters and setters for all your class' fields. So when you do this:
class Foo {
final bar
}
new Foo().bar
you're actually calling the generated method Foo.getBar().
I have a ...
Subvene asked 20/12, 2013 at 10:55
4
Solved
I have done a lot of research to find out the answer for the following to no avail.
I have the following class in one <div> tag in the HTML.
<button type='button' class='btn btn-navbar d...
Logwood asked 28/11, 2013 at 12:7
1
Solved
I'm trying to write functional test with Spock and Geb.
I want to use in one test method multiple blocks of when/then with where for each block. Is it possible? Or I should use one where for all t...
3
Solved
Spock has great assertion support. But I've got one problem - I wanna add more context data (for example url of the checked page) to assertion info.
I've tried
assert a == b, [context] but in this...
1
Solved
There are code snippets in this Spock wiki page that involve double right arrow operators (>>). For example:
setup:
subscriber.isAlive() >> true
So, what does the >> operator mean in this ...
2
Solved
Is it possible to pass a value in where block like this.
I have tried this. But it fails and gives MissingPropertyException.
And I want the name1 and name2 to be inside the method.
def "length ...
Catalyze asked 25/9, 2013 at 21:8
2
Solved
I have a EncouragementService.groovy with following method
class EncouragementService {
def stripePaymentService
def encourageUsers(List<User> users){
if(null != users && users...
Yellowlegs asked 5/9, 2013 at 19:40
4
Solved
I'd like to test a Grails controller that is sending out emails using the grails Email plugin. I'm at a loss exactly how to mock the sendMail closure in order for interactions to work. Here's my la...
1
Solved
I am writing some Spock spec based unit tests under Grails 2.1.1. I'm having trouble getting springSecurityService injected into my domain object that is used by my unit.
This is what I have so fa...
Irreversible asked 8/8, 2013 at 17:31
1
I have more general question. Which framework or implementation I should use for mocking in Grails 2.x when using Spock?
I know tons of mocking style: leverage Groovy metaClass, Grails mockFor(), ...
Macgregor asked 24/7, 2013 at 8:48
1
Solved
I am using Selenium and Spock for testing my application. Running tests that need System properties from Maven or my IDE works like a charm, but Gradle is getting null values.
@Shared
private int ...
1
I have a java class which i test in groovy/spock. The java class has a final field:
private static final log = Logger.getLogger(...)
I want to test if a method uses this logger, preferably using...
© 2022 - 2024 — McMap. All rights reserved.