No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
buildSrc/src/main/groovy
ci
res/main/groovy
src
.gitignore
.travis.yml
LICENSE
README.md
README.md.base
build.gradle
build.gradle.offline
settings.gradle
settings.gradle.offline

README.md

Gradle-Cobol-Plugin-UnitTest-Extension

Build Status

This plugin extends the existing gradle-cobol-plugin for unittests.

This gradle plugin is based on the existing github project cobol-unit-test.

The new source code if fully backward compatible, but enables new features:

  • No redundant configuration (the plugin provides a default-configuration for all tests)
  • Fast and simple test execution by gradle with the task :cobolUnit
  • Simple testcoverage computation with task cobolUnit computeTestCoverage . This task generates a cobertura-testcoverage xml file.
  • Integration tests (full application + ressource build)
  • Integration tests with specific ressource files

Gradle-cobol environment

Further Reading:

Supported versions

Compiler Code format unit test unit test testcoverage integration test integration test coverage
GnuCobol / Open Cobol 1.1 fixed full support full support --- ---
GnuCobol 2 fixed full support full support full support full support
GnuCobol 3rc fixed full support full support full support full support

Installation

Add the plugin to the gradle-cobol-plugin classpath:

build.gradle:

buildscript {
	 dependencies {
		classpath group: 'de.sebastianruziczka', name: 'gradle-cobol-plugin-unittest-extension', version: 'latest'
	}
}

plugins {
	id 'de.sebastianruziczka.Cobol' version 'latest'
}

Or hardcode specific versions in your build.gradle (not preferred):

buildscript {
	 dependencies {
		classpath group: 'de.sebastianruziczka', name: 'gradle-cobol-plugin-unittest-extension', version: '0.0.30'
	}
}

plugins {
	id 'de.sebastianruziczka.Cobol' version '0.0.40'
}

settings.gradle:

pluginManagement {
	repositories {
		maven {
			url 'https://sebastianruziczka.de/repo/mvn/'
		}
	}
}

Comparison unit <-> integration tests

unit test integration test
gradle command testUnit testIntegration
testcoverage available 1) available 2)
compile strategy compile test and target compile all cobol sourcefiles
ressource strategy no ressources available use sources in /res/main/cobol and res/integrationtest/cobol/<testname>
additional env variables COBC_INTERACTIVE='N' COBC_INTERACTIVE='N'
failing test kills check yes yes
  1. set unittestCodeCoverage = true in your build gradle and execute tasks testUnit computeTestcoverage

  2. set integrationtestCodeCoverage = true in your build gradle and execute tasks testIntegration computeIntegrationTestCoverage

Unit tests

File conventions:

  • Source file (target): <module>/<filename>.<cobol.srcFileType> e.g. CRTDB/MAIN.cbl
  • Test file : <module>/<filename><cobol.unittestPostfix>.<cobol.srcFileType> e.g. CRTDB/MAINUT.cbl
  • Note: properties starting with cobol. are configured in your cobol-block in your build.gradle

Integration tests

  • Source file (target): <module>/<filename>.<cobol.srcFileType> e.g. CRTDB/MAIN.cbl
  • Test file : <module>/<filename><cobol.integrationtestPostfix>.<cobol.srcFileType> e.g. CRTDB/MAINIT.cbl
  • Test ressources: <cobol.resIntegrationTest>/<module>/<filename>/ e.g. res/integrationtest/cobol/CRTDB/MAIN/. All items in this folder will be copied in your build/exectution-directory of our integration test. Ressources from res/main/cobol will be replaced.
  • Note: properties starting with cobol. are configured in your cobol-block in your build.gradle

Example with default settings:

Source Directory:
	- src/main/cobol/CRTDB/MAIN.cbl
	- src/main/cobol/CRTDB/OTHER.cbl

Test Directory:
	- src/test/cobol/CRTDB/MAINIT.cbl --> Integration Test

Ressources:
	- res/main/cobol/CRTDB/database1.db --> ressource version
	- res/main/cobol/CRTDB/database2.db --> ressource version

Integration test ressources
	- res/integrationtest/cobol/CRTDB/MAIN/CRTDB/database1.db --> integrationtest version

The cobol integration test for the file CRTDB/MAIN.cbl will contain the following files:

Integration test directory:
	- $dir/CRTDB/MainIT.so
	- $dir/CRTDB/OTHER.so
	- $dir/CRTDB/database1.db --> integrationtest version (replaced ressource version)
	- $dir/CRTDB/database2.db --> ressource version