Author: jleroux
Date: Mon Nov 12 10:57:27 2018 New Revision: 1846393 URL: http://svn.apache.org/viewvc?rev=1846393&view=rev Log: Improved: Allow unit tests to be written in Groovy (OFBIZ-10611) Since OFBIZ-9996 it is possible to write integration tests in Groovy, meaning test that depend on the dispatcher and the delegator. It would be nice if the unit tests could be written in Groovy too. The major benefit of writing tests in Groovy is that you create inputs and expected outputs more easily with objects literals. For example the following java code: Map<String, Integer> input = new HashMap<>(); input.put("foo", 42); input.put("bar", 37); can be rewritten in Groovy like this: def input = [foo: 42, bar: 37] Thanks: Mathieu Lirzin Added: ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/FileUtilTests.groovy - copied, changed from r1846388, ofbiz/ofbiz-framework/trunk/framework/base/groovyScript/test/FileUtilTests.groovy Removed: ofbiz/ofbiz-framework/trunk/framework/base/groovyScript/test/FileUtilTests.groovy Modified: ofbiz/ofbiz-framework/trunk/build.gradle Modified: ofbiz/ofbiz-framework/trunk/build.gradle URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1846393&r1=1846392&r2=1846393&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/build.gradle (original) +++ ofbiz/ofbiz-framework/trunk/build.gradle Mon Nov 12 10:57:27 2018 @@ -34,6 +34,7 @@ buildscript { } } apply plugin: 'java' +apply plugin: 'groovy' apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: "at.bxm.svntools" @@ -233,6 +234,9 @@ sourceSets { srcDirs = getDirectoryInActiveComponentsIfExists('src/main/java') exclude excludedJavaSources } + groovy { + srcDirs = getDirectoryInActiveComponentsIfExists('src/main/groovy') + } resources { srcDirs = getDirectoryInActiveComponentsIfExists('src/main/java') srcDirs += getDirectoryInActiveComponentsIfExists('config') @@ -256,6 +260,9 @@ sourceSets { java { srcDirs = getDirectoryInActiveComponentsIfExists('src/test/java') } + groovy { + srcDirs = getDirectoryInActiveComponentsIfExists('src/test/groovy') + } resources { srcDirs = getDirectoryInActiveComponentsIfExists('src/test/java') } Copied: ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/FileUtilTests.groovy (from r1846388, ofbiz/ofbiz-framework/trunk/framework/base/groovyScript/test/FileUtilTests.groovy) URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/FileUtilTests.groovy?p2=ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/FileUtilTests.groovy&p1=ofbiz/ofbiz-framework/trunk/framework/base/groovyScript/test/FileUtilTests.groovy&r1=1846388&r2=1846393&rev=1846393&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/groovyScript/test/FileUtilTests.groovy (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/test/groovy/org/apache/ofbiz/base/util/FileUtilTests.groovy Mon Nov 12 10:57:27 2018 @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -15,20 +15,18 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - *******************************************************************************/ - + */ +package org.apache.ofbiz.base.util; import org.apache.commons.io.FileUtils -import org.apache.ofbiz.base.util.FileUtil -import org.apache.ofbiz.base.util.UtilProperties -import org.apache.ofbiz.testtools.GroovyScriptTestCase - -class FileUtilTests extends GroovyScriptTestCase { +import org.junit.Test +public class FileUtilTests { /** * Test FileUtil zipFileStream and unzipFileToFolder methods, using README.adoc */ - void testZipReadme() { + @Test + void zipReadme() { String zipFilePath = UtilProperties.getPropertyValue("general", "http.upload.tmprepository", "runtime/tmp") String zipName = 'README.adoc.zip' String fileName = 'README.adoc' |
Free forum by Nabble | Edit this page |