How to use JGivenTaskExtension class of com.tngtech.jgiven.gradle package

Best JGiven code snippet using com.tngtech.jgiven.gradle.JGivenTaskExtension

Source:JGivenPlugin.java Github

copy

Full Screen

...29 project.getTasks().withType(Test.class).configureEach(this::applyTo);30 }31 private void applyTo(Test test) {32 final String testName = test.getName();33 final JGivenTaskExtension extension = test.getExtensions().create("jgiven", JGivenTaskExtension.class);34 final Project project = test.getProject();35 ((IConventionAware) extension).getConventionMapping().map("resultsDir",36 (Callable<File>) () -> project.file(project.getBuildDir() + "/jgiven-results/" + testName));37 File resultsDir = extension.getResultsDir();38 if (resultsDir != null) {39 test.getOutputs().dir(resultsDir).withPropertyName("jgiven.resultsDir");40 }41 /* Java lambda classes are created at runtime with a non-deterministic classname.42 * Therefore, the class name does not identify the implementation of the lambda,43 * and changes between different Gradle runs.44 * See: https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:how_does_it_work45 */46 //noinspection Convert2Lambda47 test.prependParallelSafeAction(new Action<Task>() {48 @Override49 public void execute(Task task) {50 ((Test) task).systemProperty(Config.JGIVEN_REPORT_DIR, extension.getResultsDir().getAbsolutePath());51 }52 });53 }54 private void configureJGivenReportDefaults(Project project) {55 project.getTasks()56 .withType(JGivenReportTask.class).forEach(reportTask ->57 reportTask.getReports().all((Action<Report>) report ->58 report.getRequired().convention(report.getName().equals(JGivenHtmlReportImpl.NAME))59 ));60 }61 private void addDefaultReports(final Project project) {62 final ReportingExtension reportingExtension = Objects.requireNonNull(63 project.getExtensions().findByType(ReportingExtension.class));64 project.getTasks().withType(Test.class).forEach(test -> project.getTasks()65 .register("jgiven" + WordUtil.capitalize(test.getName()) + "Report", JGivenReportTask.class)66 .configure(reportTask -> configureDefaultReportTask(test, reportTask, reportingExtension))67 );68 }69 private void configureDefaultReportTask(final Test test, JGivenReportTask reportTask,70 final ReportingExtension reportingExtension) {71 reportTask.mustRunAfter(test);72 ConventionMapping mapping = ((IConventionAware) reportTask).getConventionMapping();73 Callable<File> getResultsDirectory = () -> test.getExtensions()74 .getByType(JGivenTaskExtension.class)75 .getResultsDir();76 mapping.map("results", getResultsDirectory);77 Objects.requireNonNull(mapping.getConventionValue(reportTask.getReports(), "reports", false))78 .all(report -> {79 ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();80 String relativeFilePath = "jgiven" + "/" + test.getName() + "/" + report.getName();81 Callable<File> getDestination = () -> reportingExtension.file(relativeFilePath);82 reportMapping.map("destination", getDestination);83 });84 }85}...

Full Screen

Full Screen

Source:JGivenTaskExtension.java Github

copy

Full Screen

1package com.tngtech.jgiven.gradle;2import java.io.File;3public class JGivenTaskExtension {4 private File resultsDir;5 public File getResultsDir() {6 return resultsDir;7 }8 public void setResultsDir( File resultsDir ) {9 this.resultsDir = resultsDir;10 }11}...

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1import com.tngtech.jgiven.gradle.JGivenTaskExtension2import com.tngtech.jgiven.gradle.JGivenReportTask3plugins {4}5repositories {6 mavenCentral()7}8dependencies {

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1import com.tngtech.jgiven.gradle.JGivenTaskExtension2import com.tngtech.jgiven.gradle.JGivenPlugin3buildscript {4 repositories {5 mavenCentral()6 }7 dependencies {8 }9}10sourceSets {11 main {12 java {13 }14 }15 test {16 java {17 }18 }19}20repositories {21 mavenCentral()22}23dependencies {24}25jgiven {26 report {27 }28}29task jgivenReport(type: JGivenTaskExtension) {30}31import com.tngtech.jgiven.gradle.JGivenTaskExtension32import com.tngtech.jgiven.gradle.JGivenPlugin33buildscript {34 repositories {35 mavenCentral()36 }37 dependencies {38 }39}40sourceSets {41 main {42 java {43 }44 }45 test {46 java {47 }48 }49}50repositories {51 mavenCentral()52}53dependencies {54}55jgiven {56 report {57 }58}59task jgivenReport(type: JGivenTaskExtension) {

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1package com.tngtech.jgiven.gradle;2import org.gradle.api.Project;3import org.gradle.api.tasks.testing.Test;4import org.gradle.api.tasks.testing.TestTaskReports;5import org.gradle.api.tasks.testing.logging.TestExceptionFormat;6import org.gradle.api.tasks.testing.logging.TestLogging;7import org.gradle.api.tasks.testing.logging.TestLoggingContainer;8import java.io.File;9public class JGivenTaskExtension extends Test {10 public JGivenTaskExtension(Project project) {11 super(project);12 this.setTestLogging(new TestLoggingContainer());13 this.getTestLogging().setExceptionFormat(TestExceptionFormat.FULL);14 this.getTestLogging().setShowCauses(true);15 this.getTestLogging().setShowExceptions(true);16 this.getTestLogging().setShowStackTraces(true);17 this.getTestLogging().setShowStandardStreams(true);18 this.setTestReportDir(new File(project.getBuildDir(), "reports/tests"));19 this.setTestResultsDir(new File(project.getBuildDir(), "test-results"));20 this.setTestReport(new TestTaskReports());21 this.getTestReport().setHtml(new File(this.getTestReportDir(), "html"));22 this.getTestReport().setXml(new File(this.getTestReportDir(), "xml"));23 this.setGroup("Verification");24 this.setDescription("Run JGiven tests");25 }26}27package com.tngtech.jgiven.gradle;28import org.gradle.api.Plugin;29import org.gradle.api.Project;30import org.gradle.api.Task;31import org.gradle.api.plugins.JavaBasePlugin;32import org.gradle.api.tasks.testing.Test;33import java.io.File;34public class JGivenPlugin implements Plugin<Project> {35 public void apply(Project project) {36 project.getPluginManager().apply(JavaBasePlugin.class);37 JGivenTaskExtension jGivenTaskExtension = new JGivenTaskExtension(project);38 jGivenTaskExtension.setGroup("Verification");39 jGivenTaskExtension.setDescription("Run JGiven tests");40 jGivenTaskExtension.setTestClassesDirs(project.files(new File(project.getBuildDir(), "classes/java/main")));41 jGivenTaskExtension.setClasspath(project.getConfigurations().getByName("testRuntimeClasspath"));42 jGivenTaskExtension.setTestResultsDir(new File(project.getBuildDir(), "test-results"));43 jGivenTaskExtension.setTestReportDir(new File(project.getBuildDir(), "reports/tests"));

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1jgiven {2}3repositories {4 mavenCentral()5}6dependencies {7}8test {9 useJUnitPlatform()10 testLogging {11 }12}13task runJGivenTests(type: com.tngtech.jgiven.gradle.JGivenTaskExtension) {14}15jgiven {16}17repositories {18 mavenCentral()19}20dependencies {21}22test {23 useJUnitPlatform()24 testLogging {25 }26}27task runJGivenTests(type: com.tngtech.jgiven.gradle.JGivenTaskExtension) {28}29jgiven {30}31repositories {32 mavenCentral()33}34dependencies {35}36test {37 useJUnitPlatform()38 testLogging {39 }40}41task runJGivenTests(type: com.tngtech.jgiven.gradle.JGivenTaskExtension) {42}

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1plugins {2}3repositories {4 jcenter()5}6dependencies {7}8jgiven {9 htmlReport {10 }11}12test {13 useJUnitPlatform()14}15task aggregate(type: com.tngtech.jgiven.gradle.JGivenTaskExtension) {16 inputDir = file('build/jgiven-reports')17 outputDir = file('build/jgiven-reports')18}

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1plugins {2}3repositories {4 mavenCentral()5}6dependencies {7}8test {9 useJUnit()10}11jgiven {12 reportDir = file("$buildDir/reports/jgiven-report")13}14jgivenTest {15}16task jgivenTestReport(type: JGivenTaskExtension, dependsOn: 'test') {17 reportDir = file("$buildDir/reports/jgiven-report")18}19plugins {20}21repositories {22 mavenCentral()23}24dependencies {25}26test {27 useJUnit()28}29jgiven {

Full Screen

Full Screen

JGivenTaskExtension

Using AI Code Generation

copy

Full Screen

1import com.tngtech.jgiven.gradle.JGivenTaskExtension2import org.gradle.api.Project3import org.gradle.api.tasks.testing.Test4task jgivenReport(type: JGivenTaskExtension, dependsOn: test) {5 reportDir = file("$buildDir/jgiven-reports")6 testClassesDir = file("build/classes/test")7 sourceClassesDir = file("build/classes/main")8}9task test(type: Test) {10 testClassesDir = file("build/classes/test")11 sourceClassesDir = file("build/classes/main")12}13Project project = new ProjectBuilder().build()14JGivenTaskExtension jgivenTaskExtension = project.tasks.create(name: 'jgivenReport', type: JGivenTaskExtension)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run JGiven automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in JGivenTaskExtension

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful