7
votes

I'm attempting to setup my project to run builds on travis-CI. I've gotten it setup so that it runs and passes but my tests don't get run at all. Locally they pass. To test I setup a test to fail and the proceeding build still passed. THis is a gradle project and uses testng.

build.gradle file

group 'org.napoleon'
version '1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.1.4-3'

    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'kotlin'

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    testCompile group : 'org.testng', name : 'testng', version: '6.8'
}

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

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

test {
    // enable TestNG support (default is JUnit)
    useTestNG()
}

and travis.yml

language: java
jdk:
  - oraclejdk8
before_install:
  - chmod +x gradlew
  - chmod +x gradle/wrapper/gradle-wrapper.jar

I'm basically new to both travis-CI and kotlin so struggling with a few things as I go.

1
How do you invoke the tests locally? "./gradlew check"? Also, is there a log from travis? Can you post it? Does it say which Gradle tasks are run?Florian Wilhelm
I did have an error in my build.gradle file which caused some problems locally and your suggestion here helped me fix that. Mismatch between kotlin version in use in IDE and that in specified in the build.gradle file.menapole

1 Answers

8
votes

Try this:

language: java
jdk:
  - oraclejdk8
before_install:
  - chmod +x gradlew
  - chmod +x gradle/wrapper/gradle-wrapper.jar
script:
  - ./gradlew test build