Scala tests not executed


(Tomek Kaleda) #1

Hello

I’m using gradle 1.1 on Windows 7 64-bit with Java 1.7.0_05 64-bit. I have the same problem also with gradle 1.0.

I have a simple gradle project that uses scala plugin. My build.gradle file has plugins: apply plugin: ‘scala’ apply plugin: ‘eclipse’

There is one source file src/main/scala/%package_directories%/LevelEx.scala directory and one test file src/test/scala/%package_directories%/LevelExTest.scala.

My test class looks like this:

import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.testng.Assert; import org.testng.annotations.Test;

class LevelExTest {

val LOGGER_NAME = “test.log”;

@Test

def getLogger(): Unit =

{

println("################ getLogger #################")

val logger = Logger.getLogger(LOGGER_NAME);

Assert.assertNotNull(logger, “Error: logger is null.”);

//the logger is set to L9 is test log4j.xml

Assert.assertEquals(logger.getLevel(), LevelEx.L9, “The logger level is not L9”);

} }

When I call “gradle build” everything compiles cleanly but the test is not executed. It means that even if I add false condition in the “getLogger” method or even throw an exception I always get successful build:

d:\work\gradle-logging>gradle build :compileJava UP-TO-DATE :compileScala UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar :assemble :compileTestJava UP-TO-DATE :compileTestScala UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build

BUILD SUCCESSFUL

Am I doing something wrong? How to force gradle to execute the test.

P.S. if I generate eclipse project using “gradle eclipse”, open it in eclipse then I can execute the test using eclipse command “Run as TestNG Test” so I’m sure the test file is correct.


(Tomek Kaleda) #2

Missing useTestNG() call in build.gradle