Last active
December 24, 2015 00:39
-
-
Save andrezrv/6717784 to your computer and use it in GitHub Desktop.
How to test with Spock using Build Test Data Plugin for Grails.
Spock Docs: http://docs.spockframework.org/
Build Test Data Docs & Repo: https://github.com/tednaleid/build-test-data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package myapp.downloads | |
import grails.test.mixin.TestFor | |
import spock.lang.Specification | |
import grails.buildtestdata.mixin.Build | |
/** | |
* See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions | |
*/ | |
@TestFor( Download ) | |
@Build( [ Download ] ) | |
class DownloadSpec extends Specification { | |
void "test Download.getFullName() method"() { | |
// Create some objects to test with. | |
def download = Download.build() | |
given: "Try to get full name for the person associated to the download" | |
def result = download.getFullName() | |
when: "Returned value equals the concatenation of name and lastname" | |
download.person.name + ' ' + download.person.lastName == result | |
then: "Print success message" | |
println( '# SUCCESS: Test for Download.getFullName() passed.' ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment