Skip to main content
Skip table of contents

Test Case Writing Guidelines and Examples - Gradle

Gradle is a Java Framework, we can use Junit as the test framework. This document shows how to writing a Gradle test case in Testany.

Testany test case supported Java version is JDK 11
If any new JDK version needed, please feel free to contact our Customer Support

Test case package - one zip file
Currently we are only support upload your local zip file to Testany, the zip file need contains at least one file:

  1. Test case code file or files, like StringTest.java, settings.gradle, build.gradle
    StringTest.java

    CODE
    package hello.gradle;
    
    import org.junit.jupiter.api.Test;
    import static org.junit.jupiter.api.Assertions.*;
    
    class StringTest {
        @Test void runGradleTests() {
            String testStr = System.getenv("TEST_STR");
            assertEquals("FOO", testStr);
        }
    }

    setting.gradle

    CODE
    rootProject.name = 'hello-gradle'

    build.gradle

    CODE
    plugins {
        id 'java-library'
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
    }
    
    tasks.named('test') {
        useJUnitPlatform()
    }

zip all the related files as one zip file, in this case the test case package file is gradle-test.zip

After you’ve successfully prepared the .zip file, you will be able to go to register your test case on Testany Platform. Please refer to <Managing Test Case> for the registration step-by-step guide.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.