The Artima Developer Community
Sponsored Link

SuiteRunner Forum
customizing the suiterunner

6 replies on 1 page. Most recent reply: Aug 25, 2003 4:52 PM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Neelesh Korade

Posts: 4
Nickname: neelesh
Registered: Mar, 2003

customizing the suiterunner Posted: Mar 28, 2003 5:27 AM
Reply to this message Reply
Advertisement
Hi All,
I have come across a new problem now. I want to customize the suiterunner. I have written certain Test Suites. For a Test Suite, the Artima SuiteRunner executes all the test methods inside it. I want to execute the test methods inside it selectively (based on some criteria). For instance, say based on the value of some flag, I want to execute only a subset of test methods for a given value of the flag. How to make this possible? The value of the flag ofcourse has to be passed on the command line. But I don't know how to pass a flag value to the suiterunner as a commandline parameter.
Thanx and regards
neelesh


Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: customizing the suiterunner Posted: Mar 28, 2003 7:29 AM
Reply to this message Reply
Neelesh,

Due to the design of SuiteRunner, passing parameters into test cases via the Runner class would not be an easy thing to do.

Since you want to run a subset of tests, perhaps you should place those subsets into a suite of their own and run them separately? Additionally, it is possible to specify more than one suite to be run in the SuiteRunner using the -s flag repeatedly. For example,

java -jar suiterunner.jar [-s <suiteclass> -s <suiteclass> -s <suiteclass> [...]].

If it becomes cumbersome to specify a long list of suiteclasses then you can always use recipe files.

Adam

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: customizing the suiterunner Posted: Mar 28, 2003 8:11 PM
Reply to this message Reply
> Hi All,
> I have come across a new problem now. I want to
> to customize the suiterunner. I have written certain Test
> Suites. For a Test Suite, the Artima SuiteRunner executes
> all the test methods inside it. I want to execute the
> test methods inside it selectively (based on some
> criteria). For instance, say based on the value of some
> flag, I want to execute only a subset of test methods for
> a given value of the flag. How to make this possible? The
> value of the flag ofcourse has to be passed on the
> command line. But I don't know how to pass a flag value
> to the suiterunner as a commandline parameter.
> Thanx and regards

What you need to do is override executeTestMethods in your Suite subclass. That is the method that executes test methods. You can change it to look at a Java property, which you can define on the command line, and use that to decide which test methods to invoke.

In the near future, I plan to enhance SuiteRunner so that you can specify user defined properties in the recipe file. I always planned to do this. Just haven't had time to do it yet. That will be the best way to pass user-defined properties to your executeTestMethods once the enhancement is in place. For the time being, you'll need to use plain old Java properties.

For an example of overriding the execute method, which is similar to overriding executeTestMethods, see:

http://www.artima.com/suiterunner/scriptdriven.html

Here's an example of starting SuiteRunner and specifying a Java property (with the -D):


java -DScriptFile=generatedscript.txt -jar suiterunner-1.0beta6.jar accountscript.srj


The previous example is from page 11 of the above article:

http://www.artima.com/suiterunner/scriptdriven11.html

John Smith

Posts: 5
Nickname: jeksmith
Registered: Jan, 2003

Re: customizing the suiterunner Posted: Aug 20, 2003 10:35 AM
Reply to this message Reply
Hi Bill,

There's a problem with your solution. It'd be nice to call executeTestMethod() from an overridden executeTestMethods(), but alas executeTestMethod() has package level security. I suppose this is so TestRerunner.rerun() can invoke it.

-John

Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: customizing the suiterunner Posted: Aug 22, 2003 4:45 AM
Reply to this message Reply
> There's a problem with your solution.

I prefer to call it a "feature" rather than a "problem". But that's just me.

Adam

John Smith

Posts: 5
Nickname: jeksmith
Registered: Jan, 2003

Re: customizing the suiterunner Posted: Aug 25, 2003 2:15 PM
Reply to this message Reply
Perhaps I misunderstand. Is there an easy way to do Bill's solution with 1.0Beta6? (other than cutting and pasting all of the executeTestMethod code) I have a need to select a particular test to run, so I am interested in a workable solution.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: customizing the suiterunner Posted: Aug 25, 2003 4:52 PM
Reply to this message Reply
Hi John,

> Perhaps I misunderstand. Is there an easy way to do
> Bill's solution with 1.0Beta6? (other than cutting and
> pasting all of the executeTestMethod code) I have a need
> to select a particular test to run, so I am interested in
> a workable solution.

Well, for the time being, I suppose you could simply copy the executeTestMethod method into your own subclass, if you want to use it as is. I'm not sure how easy that will be, because the method may use private data also that you need to also copy, but it shouldn't be too hard. I had thought that some people might want to use executeTestMethod the way you want to, but left it private access until I heard there was a real demand. I hear you, but will have to decide later whether or not to also make that protected.

Flat View: This topic has 6 replies on 1 page
Topic: Suite Destructor? Previous Topic   Next Topic Topic: TestMethod creation using metadata

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use