Separate unit and integration tests in Gradle Project

Let’s say we have to implement some integration tests within our gradle project and we want to keep them separately from unit tests.

The project in this case may look like:

So, we have three folders: main (with sources), test (with unit tests), and it (with integration tests).

Using gradle Groovy DSL, we can set it up the project like below:

plugins {
	id 'org.springframework.boot' version '2.3.0.RELEASE'
	id 'io.spring.dependency-management' version '1.0.9.RELEASE'
	id 'java'
}

group = 'com.dicoelogics'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
	mavenCentral()
}

configurations {
	integrationTestCompile.extendsFrom testCompile
	integrationTestRuntime.extendsFrom testRuntime
	integrationTestImplementation.extendsFrom testImplementation
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'

	testImplementation('org.springframework.boot:spring-boot-starter-test')
	integrationTestCompile('org.springframework.boot:spring-boot-starter-test')
}

sourceSets {
	integrationTest {
		java {
			compileClasspath += main.output + test.output
			runtimeClasspath += main.output + test.output
			srcDir file('src/it/java')
		}
		resources.srcDir file('src/it/resources')
	}
}

task integrationTest(type: Test) {
	setTestClassesDirs(sourceSets.integrationTest.output)
	classpath = sourceSets.integrationTest.runtimeClasspath
}

test {
	useJUnitPlatform()
}

Here we defined a new sourceSet, called integrationTest, where we specified where integration test sources are located in. After that we defined a corresponding Gradle task integrationTest.

Now we can run integration tests using command:

./gradlew integrationTest

606
Leave a Reply

avatar
  Subscribe  
newest oldest most voted
Notify of
trackback

acyclovir for shingles

acyclovir for shingles

trackback

amoxicillin 500 cost

amoxicillin 500 cost

trackback

what is aricept

what is aricept

trackback

amoxicillin canadian pharmacy

amoxicillin canadian pharmacy

trackback

azithromycin 500g tablets

azithromycin 500g tablets

trackback

interactions for cefdinir

interactions for cefdinir

trackback

cephalexin antibiotic

cephalexin antibiotic

trackback

clindamycin antibiotic

clindamycin antibiotic

trackback

erythromycin 2 gel cost

erythromycin 2 gel cost

trackback

side effects for azithromycin

side effects for azithromycin

trackback

viagra and cialis together

viagra and cialis together

trackback

generic cialis 20mg

generic cialis 20mg

trackback

cialis 100mg india

cialis 100mg india

trackback

sildenafil from mexico

sildenafil from mexico

trackback

sildenafil 100mg capsule

sildenafil 100mg capsule

trackback

cialis blood pressure

cialis blood pressure

trackback

levitra 20mg for sale

levitra 20mg for sale

trackback

canadian viagra

canadian viagra

trackback

cialis 5mg price cvs

cialis 5mg price cvs

trackback

generic price for cialis

generic price for cialis

trackback

viagra like pills

viagra like pills

trackback

sildenafil tablets 150mg

sildenafil tablets 150mg

trackback

women taking viagra

women taking viagra

trackback

hydroxychloroquine coronavirus clinical trial

value streptokinase fully

trackback

sildenafil 50mg india

sildenafil 50mg india

trackback

cheap viagra canada

cheap viagra canada

trackback

viagra gum

viagra gum

trackback

cheap indian viagra

cheap indian viagra

trackback

amlodipine 5 mg

amlodipine 5 mg

trackback

tadalafil canada

tadalafil canada

trackback

levitra drugstore

levitra drugstore

trackback

metformin xr

metformin xr

trackback

generic tadalafil daily

generic tadalafil daily

junimeridio
Guest

recruit hydroxychloroquine vietnam war immediate https://hydroxychloroquined.online/ – hydroxychloroquine 100 mg tablet ventricular fibrillation hydroxychloroquine for sale canada

trackback

amoxicillin warnings

amoxicillin warnings

trackback

doxycycline precautions

doxycycline precautions

trackback

furosemide brand name

furosemide brand name

trackback

xenical nz

xenical nz

trackback

dapoxetine tablets 60 mg

dapoxetine tablets 60 mg

trackback

finasteride 1mg

finasteride 1mg

trackback

bimatoprost rx

bimatoprost rx

trackback

clomiphene for male hypogonadism

clomiphene for male hypogonadism

trackback

fluconazole cream medication

fluconazole cream medication

trackback

domperidone pharmacodynamics

domperidone pharmacodynamics

trackback

hydroxychloroquine for cows

Separate unit and integration tests in Gradle Project – Dicelogics

Kiashoox
Guest
trackback

nolvadex lek

nolvadex lek

Lisashoox
Guest
trackback

prednisolone 100mg haematology

prednisolone 100mg haematology

trackback

naltrexone

naltrexone