Pass system parameter to TestNG/JUnit executor test

160 views
Skip to first unread message

bushne...@gmail.com

unread,
Jun 29, 2017, 7:43:36 AM6/29/17
to codename-taurus
Hello,

I will be very glad if you can help me with one issue. I have automation framework which can be run across different environments. Different configuration for different envs managed in the way that during test command you need to provide system parameter in this way: mvn clean test -Dtest=MyTest -Dtest.env=PROD

Now I want to implement few performance tests using the existing approach. I want to use few JUnit tests as test sampler. My test use dependencies from few modules (project itself is muti-module). In this case I have to build jar with all dependencies inside and provide that jar as " additional-classpath" option. The problem for me, that Taurus script doesn't now anything about "test.env" system param which should be provided on flight. Is there a way to pass system var in bzt command or somewhere else? Or maybe there are some best practices which help me to manage my issue? 

ta...@blazemeter.com

unread,
Jun 30, 2017, 4:20:15 AM6/30/17
to codename-taurus, bushne...@gmail.com
Hi.
Are you looking for something similar to 'java-opts' in gatling executor, right? (http://gettaurus.org/docs/Gatling/#Configuration-Options)
Sorry, it isn't implemented yet for selenium/junit. Probably we'll add this option soon.
As workaround please try to set JAVA_OPTS environment variable to "-Dtest=MyTest -Dtest.env=PROD" and run bzt. 
Let us know the result

---
Taras

Yuri Bushnev

unread,
Jun 30, 2017, 5:02:08 AM6/30/17
to ta...@blazemeter.com, codename-taurus
Hi, 

Thanks for your response and for the tip. Unfortunatly, it didn't work for me for some reason. I'll let you know in case if I find some another workaround for my case. 

Iurii.
--
-- 
Iurii Bushnev
Software Developer in Test
AlphaSense  |  Tammasaarenkatu 3  |  00180 Helsinki, Finland
Mobile: +358 40 866 82 85

ta...@blazemeter.com

unread,
Jun 30, 2017, 5:26:53 AM6/30/17
to codename-taurus, ta...@blazemeter.com, bushne...@gmail.com
I'm sorry. If you use linux/mac you have to export this variable to get it in java. 
Does this type of sending of values work without taurus  and how do you read this vars in java?

---
Taras

Yuri Bushnev

unread,
Jun 30, 2017, 6:25:24 AM6/30/17
to ta...@blazemeter.com, codename-taurus
In java I read these options in this way: 
environmentUnderTest = EnvironmentUnderTest.valueOf(System.getProperty("test.env"));
After I make a build, in target directory I have folder 'classes' which contain property file with not substituted param: environment.under.test=${test.environment}


But I could manage my issue with a bit another approach for reading properties. Keep long story short I could manage that by properties maven plugin. During creation of jar I just create a separate config file with already substituted variables. 
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>${project.build.outputDirectory}/test.properties</outputFile>
</configuration>
</execution>
</executions>
</plugin>
In this case in folder 'classes' in target I have new property file with environment.under.test=PROD inside. And in java I just read configs form that property file. But my initial question was not more about about issue but I was just wondering if there is a way to push maven/java options during taurus script execution. 

Thank you for help! 
Iurii. 




Reply all
Reply to author
Forward
0 new messages