Quantcast

Need to run Exec task of gradle for different environments

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Need to run Exec task of gradle for different environments

sag7221
This post has NOT been accepted by the mailing list yet.
Hi,

I am new to gradle and learning it gradually.
I need to run my python integration tests via gradle on local environment and also dev env.
Goal is to run my tests from commandline against a particular env. Such as:
gradle -Penv=local pythontest

With above command, my python tests need to run on local env, url: localhost:8665/local

With:
gradle -Penv=qa pythontest

My python tests need to run on QA env: url: idp.test.solutions.net:8665/data

I so far have a task setup:

task pythontest (type: Exec) {
        workingDir './API'
        commandLine 'nosetests', '-v', 'PyAPITests.py'
        if (project.hasProperty("env")) {
            args = [env]
             
        }  
     }  

Not able to figure out how to set my urls inside this task. Also not sure if python tests can accept the url from here.

This is different from Java tests, where it was relatively easier to set the -Penv, via testng and made changes to my 'test' task:
test {
useTestNG(){
            useDefaultListeners = true
            ignoreFailures = true
            jvmArgs '-Xmx3048m', '-XX:MaxPermSize=256m'
            includeGroups 'fast'
   
            if(project.hasProperty('env')){
                ext.testngfile = "src/test/resources/" + "$env"  + "_testng.xml"
             } else {
                ext.testngfile = "src/test/resources/local_testng.xml"
             }  
            //setup the testng.xml file with env
            options.suites(ext.testngfile)
        }  
        }  

I have files, qa_testng.xml and local_testng.xml
Loading...