API's does not run when run command gradle build












0














I am working on API automation where I have used rest assured and Gradle for my build.
When I run the command Gradle build in terminal it not run my API which is declared in the main class.



my build.gradle my is as follows



  plugins {
id 'java'
}

sourceSets {
main.java.srcDir "src/main"
main.resources.srcDir "src/main/resources"
}
group 'com.API_AUTO'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}
dependencies {
compile 'io.rest-assured:rest-assured:3.0.0'
//compile "io.rest-assured, name: rest-assured, version: 3.0.2"
compile group: 'org.testng', name: 'testng', version: '6.10'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'net.sourceforge.jexcelapi', name: 'jxl', version: '2.6.12'
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.5.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: '1.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: "com.github.fge", name: "json-schema-validator", version: "2.2.6"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
compile group: 'org.json', name: 'json', version: '20160810'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'com.google.code.guice-repository', name: 'guice-repository', version: '2.1.0'
compile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
compile group: 'com.opencsv', name: 'opencsv', version: '4.1'
testCompile 'junit:junit:4.12'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
compile 'com.relevantcodes:extentreports:2.41.2'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile 'javax.mail:javax.mail-api:1.6.2'
compile 'com.sun.mail:smtp:1.6.2'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'

}
/*jar {
from('src/main/java') {
include 'resource/extent-config.xml'
include 'resource/config.properties'
}
from configurations.compile.collect { zipTree it }
manifest.attributes "Main-Class": "com.xxxx.yyy.mainRunner"
}*/

configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "com.xxxx.yyy.mainRunner"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}
}
}


Then my mainclass is as follows-



    import Api_Test_Scripts.RunnerSub;

public class mainRunner {
public static void main(String args) throws InterruptedException {
RunnerSub obj= new RunnerSub();
obj.starttest();
obj.runner();
obj.endReport();
}
}


My expectation here is when I run the command Gradle build in terminal it should start executing the API.










share|improve this question
























  • you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
    – Stultuske
    Oct 1 at 5:58










  • @Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
    – Sobhit Sharma
    Oct 1 at 7:03










  • you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
    – Stultuske
    Oct 1 at 7:06










  • Not helping me. Still thanks for your time. @Stultuske
    – Sobhit Sharma
    Oct 1 at 7:40
















0














I am working on API automation where I have used rest assured and Gradle for my build.
When I run the command Gradle build in terminal it not run my API which is declared in the main class.



my build.gradle my is as follows



  plugins {
id 'java'
}

sourceSets {
main.java.srcDir "src/main"
main.resources.srcDir "src/main/resources"
}
group 'com.API_AUTO'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}
dependencies {
compile 'io.rest-assured:rest-assured:3.0.0'
//compile "io.rest-assured, name: rest-assured, version: 3.0.2"
compile group: 'org.testng', name: 'testng', version: '6.10'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'net.sourceforge.jexcelapi', name: 'jxl', version: '2.6.12'
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.5.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: '1.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: "com.github.fge", name: "json-schema-validator", version: "2.2.6"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
compile group: 'org.json', name: 'json', version: '20160810'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'com.google.code.guice-repository', name: 'guice-repository', version: '2.1.0'
compile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
compile group: 'com.opencsv', name: 'opencsv', version: '4.1'
testCompile 'junit:junit:4.12'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
compile 'com.relevantcodes:extentreports:2.41.2'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile 'javax.mail:javax.mail-api:1.6.2'
compile 'com.sun.mail:smtp:1.6.2'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'

}
/*jar {
from('src/main/java') {
include 'resource/extent-config.xml'
include 'resource/config.properties'
}
from configurations.compile.collect { zipTree it }
manifest.attributes "Main-Class": "com.xxxx.yyy.mainRunner"
}*/

configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "com.xxxx.yyy.mainRunner"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}
}
}


Then my mainclass is as follows-



    import Api_Test_Scripts.RunnerSub;

public class mainRunner {
public static void main(String args) throws InterruptedException {
RunnerSub obj= new RunnerSub();
obj.starttest();
obj.runner();
obj.endReport();
}
}


My expectation here is when I run the command Gradle build in terminal it should start executing the API.










share|improve this question
























  • you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
    – Stultuske
    Oct 1 at 5:58










  • @Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
    – Sobhit Sharma
    Oct 1 at 7:03










  • you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
    – Stultuske
    Oct 1 at 7:06










  • Not helping me. Still thanks for your time. @Stultuske
    – Sobhit Sharma
    Oct 1 at 7:40














0












0








0







I am working on API automation where I have used rest assured and Gradle for my build.
When I run the command Gradle build in terminal it not run my API which is declared in the main class.



my build.gradle my is as follows



  plugins {
id 'java'
}

sourceSets {
main.java.srcDir "src/main"
main.resources.srcDir "src/main/resources"
}
group 'com.API_AUTO'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}
dependencies {
compile 'io.rest-assured:rest-assured:3.0.0'
//compile "io.rest-assured, name: rest-assured, version: 3.0.2"
compile group: 'org.testng', name: 'testng', version: '6.10'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'net.sourceforge.jexcelapi', name: 'jxl', version: '2.6.12'
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.5.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: '1.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: "com.github.fge", name: "json-schema-validator", version: "2.2.6"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
compile group: 'org.json', name: 'json', version: '20160810'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'com.google.code.guice-repository', name: 'guice-repository', version: '2.1.0'
compile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
compile group: 'com.opencsv', name: 'opencsv', version: '4.1'
testCompile 'junit:junit:4.12'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
compile 'com.relevantcodes:extentreports:2.41.2'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile 'javax.mail:javax.mail-api:1.6.2'
compile 'com.sun.mail:smtp:1.6.2'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'

}
/*jar {
from('src/main/java') {
include 'resource/extent-config.xml'
include 'resource/config.properties'
}
from configurations.compile.collect { zipTree it }
manifest.attributes "Main-Class": "com.xxxx.yyy.mainRunner"
}*/

configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "com.xxxx.yyy.mainRunner"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}
}
}


Then my mainclass is as follows-



    import Api_Test_Scripts.RunnerSub;

public class mainRunner {
public static void main(String args) throws InterruptedException {
RunnerSub obj= new RunnerSub();
obj.starttest();
obj.runner();
obj.endReport();
}
}


My expectation here is when I run the command Gradle build in terminal it should start executing the API.










share|improve this question















I am working on API automation where I have used rest assured and Gradle for my build.
When I run the command Gradle build in terminal it not run my API which is declared in the main class.



my build.gradle my is as follows



  plugins {
id 'java'
}

sourceSets {
main.java.srcDir "src/main"
main.resources.srcDir "src/main/resources"
}
group 'com.API_AUTO'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}
dependencies {
compile 'io.rest-assured:rest-assured:3.0.0'
//compile "io.rest-assured, name: rest-assured, version: 3.0.2"
compile group: 'org.testng', name: 'testng', version: '6.10'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.15'
compile group: 'net.sourceforge.jexcelapi', name: 'jxl', version: '2.6.12'
compile group: 'commons-lang', name: 'commons-lang', version: '2.6'
compile group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.5.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: '1.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.6'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.5'
compile group: "com.github.fge", name: "json-schema-validator", version: "2.2.6"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
compile group: 'org.json', name: 'json', version: '20160810'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'com.google.code.guice-repository', name: 'guice-repository', version: '2.1.0'
compile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10'
compile group: 'org.uncommons', name: 'reportng', version: '1.1.4'
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.5'
compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3'
compile group: 'com.opencsv', name: 'opencsv', version: '4.1'
testCompile 'junit:junit:4.12'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.6.1'
compile 'com.relevantcodes:extentreports:2.41.2'
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.0'
compile 'javax.mail:javax.mail-api:1.6.2'
compile 'com.sun.mail:smtp:1.6.2'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'

}
/*jar {
from('src/main/java') {
include 'resource/extent-config.xml'
include 'resource/config.properties'
}
from configurations.compile.collect { zipTree it }
manifest.attributes "Main-Class": "com.xxxx.yyy.mainRunner"
}*/

configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "com.xxxx.yyy.mainRunner"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}
}
}


Then my mainclass is as follows-



    import Api_Test_Scripts.RunnerSub;

public class mainRunner {
public static void main(String args) throws InterruptedException {
RunnerSub obj= new RunnerSub();
obj.starttest();
obj.runner();
obj.endReport();
}
}


My expectation here is when I run the command Gradle build in terminal it should start executing the API.







java api gradle automation build.gradle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 1 at 6:59









rahul singh Chauhan

3341314




3341314










asked Oct 1 at 5:17









Sobhit Sharma

50111




50111












  • you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
    – Stultuske
    Oct 1 at 5:58










  • @Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
    – Sobhit Sharma
    Oct 1 at 7:03










  • you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
    – Stultuske
    Oct 1 at 7:06










  • Not helping me. Still thanks for your time. @Stultuske
    – Sobhit Sharma
    Oct 1 at 7:40


















  • you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
    – Stultuske
    Oct 1 at 5:58










  • @Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
    – Sobhit Sharma
    Oct 1 at 7:03










  • you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
    – Stultuske
    Oct 1 at 7:06










  • Not helping me. Still thanks for your time. @Stultuske
    – Sobhit Sharma
    Oct 1 at 7:40
















you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
– Stultuske
Oct 1 at 5:58




you may want to read up on a few basics. an api and an entry point for an application are not the same. You also don't seem to know about naming conventions. Now this: why do you want this main method to be triggered by build, and how do you know it doesn't run?
– Stultuske
Oct 1 at 5:58












@Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
– Sobhit Sharma
Oct 1 at 7:03




@Stultuske I know it is not running because i have added logs and which not coming while running the API by command Gradle build where as same when I do with IntelliJ it does show me the logs. Also I want to run it from the main because then it will create a jar which can be run also. Without main cannot create a jar. My only expected result is when i run the command Gradle build it should start running the API's.
– Sobhit Sharma
Oct 1 at 7:03












you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
– Stultuske
Oct 1 at 7:06




you have added logs ... not according to the code you posted. It is very well possible your IntelliJ run uses other properties than your Gradle build, so don't consider that to be the "ultimate proof". But still, build is supposed to build your application, not run it.
– Stultuske
Oct 1 at 7:06












Not helping me. Still thanks for your time. @Stultuske
– Sobhit Sharma
Oct 1 at 7:40




Not helping me. Still thanks for your time. @Stultuske
– Sobhit Sharma
Oct 1 at 7:40












1 Answer
1






active

oldest

votes


















1














I found and fixed this issue.
There are two methods as follows-




  1. Basically I was trying to run the API's or you can say classes which are in main folder through build.gradle where as to perform this action.


We should have both test folder and main folder structure which basically have the test methods which invokes the main folder classes with the respective codes.



I made this below changes voila! it worked as my gradle.build was running by test defined in it.



Runner file which invokes the main



gradle.build file changes-



test {
reports {
junitXml.enabled = true
html.enabled = false
reports.junitXml.destination = file("test-output/reports/")
}
useTestNG()
{
useDefaultListeners = true
options.suites("src/test/java/testApi_Test_Scripts/smsApiAutomationSuite.xml")
options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.CustomListener'
//options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.EmailListener'
//options.listeners << 'org.uncommons.reportng.HTMLReporter'
options.listeners << 'org.uncommons.reportng.JUnitXMLReporter'
systemProperty 'org.uncommons.reportng.title', 'sms_api_automation_results'

}
testLogging.events "passed", "skipped", "failed"
testLogging.showStandardStreams = true
testLogging.exceptionFormat = "full"




  1. Add this in your build.gradle-



    apply plugin:'application'
    mainClassName = "com.XXXX.smsApi.qa.framework.mainRunner"




And viola!



If you ask me which option is better than I will choose the first one.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52584932%2fapis-does-not-run-when-run-command-gradle-build%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I found and fixed this issue.
    There are two methods as follows-




    1. Basically I was trying to run the API's or you can say classes which are in main folder through build.gradle where as to perform this action.


    We should have both test folder and main folder structure which basically have the test methods which invokes the main folder classes with the respective codes.



    I made this below changes voila! it worked as my gradle.build was running by test defined in it.



    Runner file which invokes the main



    gradle.build file changes-



    test {
    reports {
    junitXml.enabled = true
    html.enabled = false
    reports.junitXml.destination = file("test-output/reports/")
    }
    useTestNG()
    {
    useDefaultListeners = true
    options.suites("src/test/java/testApi_Test_Scripts/smsApiAutomationSuite.xml")
    options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.CustomListener'
    //options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.EmailListener'
    //options.listeners << 'org.uncommons.reportng.HTMLReporter'
    options.listeners << 'org.uncommons.reportng.JUnitXMLReporter'
    systemProperty 'org.uncommons.reportng.title', 'sms_api_automation_results'

    }
    testLogging.events "passed", "skipped", "failed"
    testLogging.showStandardStreams = true
    testLogging.exceptionFormat = "full"




    1. Add this in your build.gradle-



      apply plugin:'application'
      mainClassName = "com.XXXX.smsApi.qa.framework.mainRunner"




    And viola!



    If you ask me which option is better than I will choose the first one.






    share|improve this answer




























      1














      I found and fixed this issue.
      There are two methods as follows-




      1. Basically I was trying to run the API's or you can say classes which are in main folder through build.gradle where as to perform this action.


      We should have both test folder and main folder structure which basically have the test methods which invokes the main folder classes with the respective codes.



      I made this below changes voila! it worked as my gradle.build was running by test defined in it.



      Runner file which invokes the main



      gradle.build file changes-



      test {
      reports {
      junitXml.enabled = true
      html.enabled = false
      reports.junitXml.destination = file("test-output/reports/")
      }
      useTestNG()
      {
      useDefaultListeners = true
      options.suites("src/test/java/testApi_Test_Scripts/smsApiAutomationSuite.xml")
      options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.CustomListener'
      //options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.EmailListener'
      //options.listeners << 'org.uncommons.reportng.HTMLReporter'
      options.listeners << 'org.uncommons.reportng.JUnitXMLReporter'
      systemProperty 'org.uncommons.reportng.title', 'sms_api_automation_results'

      }
      testLogging.events "passed", "skipped", "failed"
      testLogging.showStandardStreams = true
      testLogging.exceptionFormat = "full"




      1. Add this in your build.gradle-



        apply plugin:'application'
        mainClassName = "com.XXXX.smsApi.qa.framework.mainRunner"




      And viola!



      If you ask me which option is better than I will choose the first one.






      share|improve this answer


























        1












        1








        1






        I found and fixed this issue.
        There are two methods as follows-




        1. Basically I was trying to run the API's or you can say classes which are in main folder through build.gradle where as to perform this action.


        We should have both test folder and main folder structure which basically have the test methods which invokes the main folder classes with the respective codes.



        I made this below changes voila! it worked as my gradle.build was running by test defined in it.



        Runner file which invokes the main



        gradle.build file changes-



        test {
        reports {
        junitXml.enabled = true
        html.enabled = false
        reports.junitXml.destination = file("test-output/reports/")
        }
        useTestNG()
        {
        useDefaultListeners = true
        options.suites("src/test/java/testApi_Test_Scripts/smsApiAutomationSuite.xml")
        options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.CustomListener'
        //options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.EmailListener'
        //options.listeners << 'org.uncommons.reportng.HTMLReporter'
        options.listeners << 'org.uncommons.reportng.JUnitXMLReporter'
        systemProperty 'org.uncommons.reportng.title', 'sms_api_automation_results'

        }
        testLogging.events "passed", "skipped", "failed"
        testLogging.showStandardStreams = true
        testLogging.exceptionFormat = "full"




        1. Add this in your build.gradle-



          apply plugin:'application'
          mainClassName = "com.XXXX.smsApi.qa.framework.mainRunner"




        And viola!



        If you ask me which option is better than I will choose the first one.






        share|improve this answer














        I found and fixed this issue.
        There are two methods as follows-




        1. Basically I was trying to run the API's or you can say classes which are in main folder through build.gradle where as to perform this action.


        We should have both test folder and main folder structure which basically have the test methods which invokes the main folder classes with the respective codes.



        I made this below changes voila! it worked as my gradle.build was running by test defined in it.



        Runner file which invokes the main



        gradle.build file changes-



        test {
        reports {
        junitXml.enabled = true
        html.enabled = false
        reports.junitXml.destination = file("test-output/reports/")
        }
        useTestNG()
        {
        useDefaultListeners = true
        options.suites("src/test/java/testApi_Test_Scripts/smsApiAutomationSuite.xml")
        options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.CustomListener'
        //options.listeners << 'com.kaleyra.smsApi.qa.framework.listener.EmailListener'
        //options.listeners << 'org.uncommons.reportng.HTMLReporter'
        options.listeners << 'org.uncommons.reportng.JUnitXMLReporter'
        systemProperty 'org.uncommons.reportng.title', 'sms_api_automation_results'

        }
        testLogging.events "passed", "skipped", "failed"
        testLogging.showStandardStreams = true
        testLogging.exceptionFormat = "full"




        1. Add this in your build.gradle-



          apply plugin:'application'
          mainClassName = "com.XXXX.smsApi.qa.framework.mainRunner"




        And viola!



        If you ask me which option is better than I will choose the first one.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 20 at 5:10

























        answered Nov 20 at 5:01









        Sobhit Sharma

        50111




        50111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52584932%2fapis-does-not-run-when-run-command-gradle-build%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Paul Cézanne

            UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

            Angular material date-picker (MatDatepicker) auto completes the date on focus out