Going from JUnit to spock

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Going from JUnit to spock

THUFIR HAWAT
This is literally my first go with either JUnit or spock:

// Apply the java plugin to add support for Java
   apply plugin: 'java'

// In this section you declare where to find the dependencies of your
project
     repositories {
     mavenCentral()
   }

   sourceSets {
     main {
       java {
         srcDirs 'src/main/' // where the main code is
       }
     }

     test {
       java {
         srcDir 'src/test/' // tests for all the main code
       }
     }
   }

// In this section you declare the dependencies for your production and
test code
   dependencies {
     testCompile 'junit:junit:4.11'
   }

   test {
     testLogging {
       events "passed", "skipped", "failed", "standardOut", "standardError"
     }
   }


   jar  {
     manifest {
       attributes 'Main-Class': 'net.bounceme.mordor.hello.HelloWorld'
     }
   }

task wrapper(type: Wrapper) {
     gradleVersion = '2.4.3'
}




I simply updated the dependencies method to now be:

   dependencies {
     //testCompile 'junit:junit:4.11'
     compile "org.codehaus.groovy:groovy-all:2.4.1"
     testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
   }



Is this build file reasonable?  All I did was just replace the JUnit repo
with groovy and spock.

project:  [hidden email]:THUFIR/hello_gradle.git




thanks,

Thufir

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Going from JUnit to spock

Joe Schafer
Hi,

If you apply the java plugin, the sourceSets will be set automatically, so you don't need the sourceSets block.  See https://docs.gradle.org/current/userguide/java_plugin.html for details.

Make sure to apply the groovy plugin if you want to write tests in Groovy.  That will also setup sourceSets for groovy.

Looks like it should work.

--
Joe

On Thursday, February 4, 2016 at 2:58:39 PM UTC-5, THUFIR HAWAT wrote:
This is literally my first go with either JUnit or spock:

// Apply the java plugin to add support for Java
   apply plugin: 'java'

// In this section you declare where to find the dependencies of your
project
     repositories {
     mavenCentral()
   }

   sourceSets {
     main {
       java {
         srcDirs 'src/main/' // where the main code is
       }
     }

     test {
       java {
         srcDir 'src/test/' // tests for all the main code
       }
     }
   }

// In this section you declare the dependencies for your production and
test code
   dependencies {
     testCompile 'junit:junit:4.11'
   }

   test {
     testLogging {
       events "passed", "skipped", "failed", "standardOut", "standardError"
     }
   }


   jar  {
     manifest {
       attributes 'Main-Class': 'net.bounceme.mordor.hello.HelloWorld'
     }
   }

task wrapper(type: Wrapper) {
     gradleVersion = '2.4.3'
}




I simply updated the dependencies method to now be:

   dependencies {
     //testCompile 'junit:junit:4.11'
     compile "org.codehaus.groovy:groovy-all:2.4.1"
     testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
   }



Is this build file reasonable?  All I did was just replace the JUnit repo
with groovy and spock.

project:  [hidden email]:THUFIR/hello_gradle.git




thanks,

Thufir

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...