Viewing results of junit test for gradle?

So I currently have the following build.gradle file:

apply plugin: 'java'

sourceSets {
    main {
        java {
            srcDir 'src/model'
        }
    }

    test {
        srcDirs = ["tests/model"]
    }
}

dependencies {
    compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')
    runtime fileTree(dir: 'libs', include: '*.jar')

    testCompile group: 'junit', name: 'junit', version: '4.+'
}  

that builds successfully when I type "gradle test" into the command line.

However I do the following error when running gradle test:

Creating properties on demand(a.k.a dynamic properties) has been deprecated.

As you can see, my junit tests are all in the folder test/model/ but I was wondering how do I see the results of if my junit tests passed?

You can view my repository here: https://github.com/quinnliu/WalnutiQ

Chingy,

I had to update a couple of things in your build.gradle:

source set for tests added Maven repository to get JUnit library

apply plugin: 'java'

repositories {
    mavenCentral()
}

sourceSets {
    main {
        java {
            srcDir 'src/model'
        }
    }

    test {
        java {
            srcDir 'tests/model'
        }
    }
}

dependencies {
    compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')
    runtime fileTree(dir: 'libs', include: '*.jar')

    testCompile group: 'junit', name: 'junit', version: '4.+'
}

Now, the results of $ gradle build:

bender:WalnutiQ demo$ gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processTestResources UP-TO-DATE
:testClasses
:test

model.RetinaTest > test_seeBMPImage FAILED
    java.lang.IllegalArgumentException at RetinaTest.java:25

model.MARK_I.SpatialPoolerTest > test_performSpatialPoolingOnRegion FAILED
    java.lang.IllegalArgumentException at SpatialPoolerTest.java:60

model.util.JsonFileInputOutputTest > test_saveRegionObject FAILED
    java.lang.IllegalArgumentException at JsonFileInputOutputTest.java:69

model.util.SynapsePermanencesViewerTest > test_saveRegionToBeOpenedInSynapsePermanencesViewer FAILED
    java.lang.IllegalArgumentException at SynapsePermanencesViewerTest.java:45

49 tests completed, 4 failed
:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/demo/development/tmp/WalnutiQ/build/reports/tests/index.html

I think you can take it from here :o)

PS: I would recommend to refactor your project structure to match Maven/Gradle structure, so you don't have to deal with source sets and it will make your build.gradle cleaner.

src/main/java   Production Java source
src/main/resources  Production resources
src/test/java   Test Java source
src/test/resources  Test resources
src/sourceSet/java  Java source for the given source set
src/sourceSet/resources Resources for the given source set

Testing in Java & JVM projects, Overall it's pretty neat, but it shows tests result for each single test, cluttering the console if you have hundreds of unit tests. Additionally the tests� Enabling the Gradle’s Native JUnit 5 Support. Even though Gradle 4.6 (and obviously all newer versions) has a native support for JUnit 5, this support is not enabled by default. If we want to enable it, we have to ensure that the test task uses JUnit 5 instead of JUnit 4. After we have enabled the Gradle’s native JUnit 5 support, the source

When you run gradle build or gradle test, there is a build directory that is created. This directory is where all the build artifacts are placed. Inside the build directory is a reports directory. This directory is where reports are placed. For example, pmd reports, junit reports, etc.

The JUnit reports are located in the tests directory. Open up the index.html file in a browser to view the report.

How to collect and print out tests summary in Gradle (*not the , To display the test result in the console, includes the testLogging like this: gradle. build. test { useJUnitPlatform() testLogging { events "passed",� Java examples. There are a few tools that can produce JUnit reports in Java. Gradle. In the following example, gradle is used to generate the test reports. If there are multiple test tasks defined, gradle will generate multiple directories under build/test-results/.

You can specify where the JUnit test results go with the following command within your test block.

test {
    reports.junitXml.destination = file('build/test-results/folder')
}

Gradle - How to display test result in console?, Can run our unit tests with Gradle. test task by following the instructions given in the blog post: Show Standard Out or Error Output from Tests. Now, we can run the test by executing the gradle clean test command. To verify that we're using JUnit 5 we can look at the imports. The imports for @Test and assertEquals should have a package starting with org.junit.jupiter.api: import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals;

JUnit 5 Tutorial: Running Unit Tests With Gradle, gradlew test (or gradlew.bat test from Windows), or run the test Gradle task from your IDE. ScriptFileTests > checkAgainstExpectedOutput[0] FAILED org.junit. In this view, you can see the name of the test (LoopGraph.test) and also can see � gradle test --tests your.package.TestClassName gradle test --tests your.package.TestClassName.particularMethod If you would like more information, you can consider options such as --stacktrace, or --info, or --debug. For example, when you run Gradle with the info logging level --info, it will show you the result of each test while they are running.

CSE 331 / Gradle Test Reports, As an outcome, you get the same test results on the continuous In this case, IntelliJ IDEA uses the JUnit test runner and tests are run much faster you can make IntelliJ IDEA display information about the tests processes. Testing on the JVM is a rich subject matter. There are many different testing libraries and frameworks, as well as many different types of test. All need to be part of the build, whether they are executed frequently or infrequently. This chapter is dedicated to explaining how Gradle handles

Testing in Gradle - Help, Gradle integrates with a wide range of Java and Groovy unit testing frameworks. By the end of this chapter, Apk nza ljnb eehst fsile dunre qrx dcyitorer build/test -results . BWE flies tncx'r etvp Listing 7.10. Displaying exception stack traces� I am trying to migrate from Ant build to Gradle in my project. There are a bunch of test cases (subclasses of junit.framework.TestCase) and few test suites (subclasses of junit.framework.TestSuite).

Comments
  • If the build succeeds, then the tests pass. An HTML test report is generated in build/reports/tests. Why don't you define the test source dir the same way as you do it for the main source dir?