Forum Discussion

steve_rivers's avatar
steve_rivers
Occasional Contributor
3 years ago

Report not generated from security test runner batch file

This is more of an intriguing question rather than a blocker as I have a work around

 

Since there doesn't seem to be a way to run ReadyAPI load or security tests from QA Complete I am investigating running them from a groovy script creating a process and running the appropriate testrunner.bat file.

 

Initially I created a groovy script as follows

 (took me a while to figure out how to get the runner output to the log window and i'm sure there are better ways)

def testRunnerPath = 'C:\\Program Files\\SmartBear\\ReadyAPI-3.20.2\\bin'
def suite='-sSecurity'
def testcase = '-cAutomationTest'
def securityTest = '-nAutomationTest'
def reportLoc = '-fC:\\repos\\Reports'
def reportType = '-R"SecurityTest Report"'
def reportFormat = '-FPDF'
def env = '-Eperf'
def project = 'C:\\repos\\compositeprojectdir'

def args = ['cmd.exe','/c', 'securitytestrunner.bat', suite, testcase, securityTest, reportLoc, reportType, reportFormat, env, project]
def pb = new ProcessBuilder( args )
pb.directory(new File(testRunnerPath))
log.info pb.command()
try {	
	log.info "Start..."
	Process process = pb.start()

	process.in.withReader { r -> 
	  r.eachLine { line -> 
	  	if(line.contains("WARN")) {
	    		log.warn "batch file output> ${line}"
	  	} else if (line.contains("ERROR")) {
	  		log.error "batch file output> ${line}"
	  	} else {
	  		log.info "batch file output> ${line}"
	  	}
	  }
	}
	process.waitForProcessOutput(System.out, System.err)
} catch (IOException e) {
    log.warn ("Process killed before completing! ${e}")
}  catch (Exception e) {
    log.warn ("Process killed before completing! ${e}")
} 
finally {
     log.info "End..."
}

 

This runs the security test with one small problem, the report generation step does not run.

 

However, when, after banging my head against this problem for most of the day I created a simple batch file with the command generated from the test runner UI and just ran that batch file from the groovy script the report generated correctly

def args = ['cmd.exe','/c', 'C:\\repos\\compositeprojectdir\\BatchFiles\\SecurityTest.bat' ]
def pb = new ProcessBuilder( args )
log.info pb.command()
try {	
	log.info "Start..."
	Process process = pb.start()

	process.in.withReader { r -> 
	  r.eachLine { line -> 
	  	if(line.contains("WARN")) {
	    		log.warn "batch file output> ${line}"
	  	} else if (line.contains("ERROR")) {
	  		log.error "batch file output> ${line}"
	  	} else {
	  		log.info "batch file output> ${line}"
	  	}
	  }
	}
	process.waitForProcessOutput(System.out, System.err)
} catch (IOException e) {
    log.warn ("Process killed before completing! ${e}")
}  catch (Exception e) {
    log.warn ("Process killed before completing! ${e}")
} 
finally {
     log.info "End..."
}

Batch file

Echo off
"C:\Program Files\SmartBear\ReadyAPI-3.20.2\bin\securitytestrunner.bat" -sSecurity -cAutomationTest -nAutomationTest -fC:\repos\Reports -R"SecurityTest Report" -FPDF -Eperf C:\repos\compositeprojectdir

This works and generates the report in the right place and I can work with this.

 

So, either I am missing something really obvious and will hang my head in shame when it is pointed out or there is something subtle going on that I don't understand.

 

 

  • Sort of not answering my own question here but explaining how we solved the initial problem

    It's a convoluted process but by using QA Compltete to execute a TestComplete test that executes a ReadyAPI Security Test we can do what we want.

  • steve_rivers's avatar
    steve_rivers
    Occasional Contributor

    Sort of not answering my own question here but explaining how we solved the initial problem

    It's a convoluted process but by using QA Compltete to execute a TestComplete test that executes a ReadyAPI Security Test we can do what we want.