-1

I am using POM in automation and in the test I have 3 classes. let's say test1, test2 and test3

tester is providing a class name in property file so if tester provide like test1 in a property file, I have put conditions in java code to run class based on what tester provide in property file.

But now I want to set up the same thing from Jenkins using a single build. I do not want to create 3 builds for 3 classes, So if in property file tester provide value test1, it should run class test1 from jenkins.

I did check for conditional build steps but seems could not satisfy my need.

Helping Hands
  • 5,292
  • 9
  • 60
  • 127

2 Answers2

1

Using the includeFile property of the Maven surefire plugin, you can explicitly say which Test classes should be run. You can provide this file from the command line (e.g. in Jenkins) by using an expression like -Dsurefire.includesFile={yourfile}.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Here I want to tell that if property file's x field = **test1** then include **test1**, and execute it. can you please give more detail on same? I mean I need to include test but conditional. – Helping Hands Jun 29 '19 at 08:50
0

You can proceed as before and let the tester provide the test class names in a file. That file is either already available on your system, or it can be uploaded by the tester when the Jenkins job builds. For that you have to parameterize the Jenkins job, and define a file upload parameter. See Jenkins Wiki for a start point, and these two Stackoverflow questions: How to upload a generic file into a Jenkins job? and How to use file parameter in jenkins

Now, this file upload is tedious for the testers. Why not change the job parameter to a input field respectively a text field, and provide at job build the tests class names as comma separated string respectively multi line text?

t0r0X
  • 4,212
  • 1
  • 38
  • 34
  • Yes so it is easy to set up job parameter as input and provides classnames as comma separate but I have 3 class and want to execute only 1 based on what tester has provided into property file. Yes, property file is there in workspace. – Helping Hands Jun 29 '19 at 08:33
  • Hmmm, what’s then the problem? Either use your previous solution, which worked as far as I understand, or the solution from @“JF Meier”, which is the way to go, in my opinion (the official Maven way). Or did I misunderstand the question/issue? – t0r0X Jun 29 '19 at 08:47