Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
fix: proper application of includeTestOutput and includeMainOutput
Browse files Browse the repository at this point in the history
Resolves #104
  • Loading branch information
eshepelyuk committed May 8, 2020
1 parent 3180d57 commit 3782f53
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
2 changes: 1 addition & 1 deletion sample-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.lkishalmi.gatling" version "3.3.2"
id "com.github.lkishalmi.gatling" version "3.3.3"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ class GatlingPlugin implements Plugin<Project> {
}

project.dependencies {
if (gatlingExt.includeMainOutput) {
gatlingImplementation project.sourceSets.main.output
}
if (gatlingExt.includeTestOutput) {
gatlingImplementation project.sourceSets.test.output
}

gatlingRuntimeOnly project.sourceSets.gatling.output
gatlingRuntimeOnly project.sourceSets.gatling.output
}

Expand All @@ -90,6 +82,13 @@ class GatlingPlugin implements Plugin<Project> {
implementation "org.scala-lang:scala-library:${p.extensions.getByType(GatlingPluginExtension).scalaVersion}"
gatlingImplementation "org.scala-lang:scala-library:${p.extensions.getByType(GatlingPluginExtension).scalaVersion}"
gatling "io.gatling.highcharts:gatling-charts-highcharts:${p.extensions.getByType(GatlingPluginExtension).toolVersion}"

if (gatlingExt.includeMainOutput) {
gatlingImplementation project.sourceSets.main.output
}
if (gatlingExt.includeTestOutput) {
gatlingImplementation project.sourceSets.test.output
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GatlingPluginExtension implements JvmConfigurable {

Closure simulations = DEFAULT_SIMULATIONS

def includeMainOutput = true
def includeTestOutput = true
Boolean includeMainOutput = true
Boolean includeTestOutput = true

String logLevel = "WARN"

Expand Down
38 changes: 33 additions & 5 deletions src/test/groovy/functional/WhenCompileSimulationSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package functional
import helper.GatlingFuncSpec
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.UnexpectedBuildFailure
import spock.lang.Ignore
import spock.lang.Unroll

import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
Expand Down Expand Up @@ -42,11 +43,13 @@ class WhenCompileSimulationSpec extends GatlingFuncSpec {
when:
executeGradle(GATLING_CLASSES_TASK_NAME)
then:
thrown(UnexpectedBuildFailure)
def e = thrown(UnexpectedBuildFailure)
and:
e.buildResult.output.contains(message)
where:
layout | dir
'gradle' | 'src/main'
'gradle' | 'src/test'
layout || dir || message
'gradle' | 'src/main' | "TestUtils.java:5: error: cannot find symbol"
'gradle' | 'src/test' | "not found: value TestUtils"
}

def "should not compile without required dependencies"() {
Expand All @@ -58,6 +61,31 @@ repositories { jcenter() }
when:
executeGradle(GATLING_CLASSES_TASK_NAME)
then:
thrown(UnexpectedBuildFailure)
def e = thrown(UnexpectedBuildFailure)
and:
e.buildResult.output.contains("object lang is not a member of package org.apache.commons")
}

@Ignore
def "should not compile with main output excluded"() {
given:
buildFile << "gatling { includeMainOutput = false }"
when:
executeGradle(GATLING_CLASSES_TASK_NAME)
then:
def e = thrown(UnexpectedBuildFailure)
and:
e.buildResult.output.contains("not found: value MainUtils")
}

def "should not compile with test output excluded"() {
given:
buildFile << "gatling { includeTestOutput = false }"
when:
executeGradle(GATLING_CLASSES_TASK_NAME)
then:
def e = thrown(UnexpectedBuildFailure)
and:
e.buildResult.output.contains("not found: value TestUtils")
}
}

0 comments on commit 3782f53

Please sign in to comment.