Identifying & Communicating a Parameter mismatch at Configuration Time

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Identifying & Communicating a Parameter mismatch at Configuration Time

walter.kelt
I am using the @Parameter method of providing parameters to my test methods. I have code that reads in a file that contains the key:value parameter list.
I provide this list to testng programatically. Occasionally I mess up and misspell the parameter key in my file  such that it doesn't match any of the parameters key names 
above my test method.

For example:

@Parameters({"name"})
@Test
public void myTest(String param1){
}

In my external parameter file, I might have spelled "nmae" instead of "name".

Of course, the test fails as it should (configuration failure), but there is no good evidence of what happened. I am wondering which one of the testng interfaces would
give me a clue that there was a parameter issue. I did look but unfortunately nothing jumped out at me. I already extend the TestListenerAdapter, so it would be great
if there was a way to extend a little more..

Any pointers would be appreciated !!

thanks
walter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Identifying & Communicating a Parameter mismatch at Configuration Time

Julien Herr
I'm not sure you will be able to do it by yourself.
But try IHookable, it may work.

Le mardi 1 mars 2016 20:00:23 UTC+1, walter kelt a écrit :
I am using the @Parameter method of providing parameters to my test methods. I have code that reads in a file that contains the key:value parameter list.
I provide this list to testng programatically. Occasionally I mess up and misspell the parameter key in my file  such that it doesn't match any of the parameters key names 
above my test method.

For example:

@Parameters({"name"})
@Test
public void myTest(String param1){
}

In my external parameter file, I might have spelled "nmae" instead of "name".

Of course, the test fails as it should (configuration failure), but there is no good evidence of what happened. I am wondering which one of the testng interfaces would
give me a clue that there was a parameter issue. I did look but unfortunately nothing jumped out at me. I already extend the TestListenerAdapter, so it would be great
if there was a way to extend a little more..

Any pointers would be appreciated !!

thanks
walter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Identifying & Communicating a Parameter mismatch at Configuration Time

walter.kelt
I see that there is an IParametersAnnotation interface. I will look into this to see if I can figure out how to use it. Seems that it would provide
a list of parameters from the test method. I should be able to compare these to the those that I provide programmatically.

On Wednesday, March 2, 2016 at 10:55:04 AM UTC-5, Julien Herr wrote:
I'm not sure you will be able to do it by yourself.
But try <a href="http://testng.org/doc/documentation-main.html#ihookable" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23ihookable\46sa\75D\46sntz\0751\46usg\75AFQjCNExmflFyD70Nmzwm1rOLvcxOSz_5A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\75http%3A%2F%2Ftestng.org%2Fdoc%2Fdocumentation-main.html%23ihookable\46sa\75D\46sntz\0751\46usg\75AFQjCNExmflFyD70Nmzwm1rOLvcxOSz_5A&#39;;return true;">IHookable, it may work.

Le mardi 1 mars 2016 20:00:23 UTC+1, walter kelt a écrit :
I am using the @Parameter method of providing parameters to my test methods. I have code that reads in a file that contains the key:value parameter list.
I provide this list to testng programatically. Occasionally I mess up and misspell the parameter key in my file  such that it doesn't match any of the parameters key names 
above my test method.

For example:

@Parameters({"name"})
@Test
public void myTest(String param1){
}

In my external parameter file, I might have spelled "nmae" instead of "name".

Of course, the test fails as it should (configuration failure), but there is no good evidence of what happened. I am wondering which one of the testng interfaces would
give me a clue that there was a parameter issue. I did look but unfortunately nothing jumped out at me. I already extend the TestListenerAdapter, so it would be great
if there was a way to extend a little more..

Any pointers would be appreciated !!

thanks
walter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Identifying & Communicating a Parameter mismatch at Configuration Time

walter.kelt
In reply to this post by walter.kelt
Figured it out... steps are:

* override onConfiguration failure
* use the ITestResult to get the class name and method name (I only run 1 method per testing invocation)
* use reflection to the get the parameter annotation. Use the .value on the annotation to get parameter names from the parameter annotation
* compare against the parameter names I provide via my parameter file and look for mismatches. Report the mismatches in my custom
  report file.

I'm really impressed by the flexibility and forethought put in the design. There is usually a way to make something happen. I wish there
was a high level design document to show the flow, but I'm slowly figuring it out. Thanks Cedric ! 


On Tuesday, March 1, 2016 at 2:00:23 PM UTC-5, walter kelt wrote:
I am using the @Parameter method of providing parameters to my test methods. I have code that reads in a file that contains the key:value parameter list.
I provide this list to testng programatically. Occasionally I mess up and misspell the parameter key in my file  such that it doesn't match any of the parameters key names 
above my test method.

For example:

@Parameters({"name"})
@Test
public void myTest(String param1){
}

In my external parameter file, I might have spelled "nmae" instead of "name".

Of course, the test fails as it should (configuration failure), but there is no good evidence of what happened. I am wondering which one of the testng interfaces would
give me a clue that there was a parameter issue. I did look but unfortunately nothing jumped out at me. I already extend the TestListenerAdapter, so it would be great
if there was a way to extend a little more..

Any pointers would be appreciated !!

thanks
walter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Identifying & Communicating a Parameter mismatch at Configuration Time

Cédric Beust ♔-2
Thanks, Walter. I don't know if I should be impressed or frightened by the convolutions of your solution, though :-)


-- 
Cédric


On Fri, Mar 4, 2016 at 9:46 PM, walter kelt <[hidden email]> wrote:
Figured it out... steps are:

* override onConfiguration failure
* use the ITestResult to get the class name and method name (I only run 1 method per testing invocation)
* use reflection to the get the parameter annotation. Use the .value on the annotation to get parameter names from the parameter annotation
* compare against the parameter names I provide via my parameter file and look for mismatches. Report the mismatches in my custom
  report file.

I'm really impressed by the flexibility and forethought put in the design. There is usually a way to make something happen. I wish there
was a high level design document to show the flow, but I'm slowly figuring it out. Thanks Cedric ! 


On Tuesday, March 1, 2016 at 2:00:23 PM UTC-5, walter kelt wrote:
I am using the @Parameter method of providing parameters to my test methods. I have code that reads in a file that contains the key:value parameter list.
I provide this list to testng programatically. Occasionally I mess up and misspell the parameter key in my file  such that it doesn't match any of the parameters key names 
above my test method.

For example:

@Parameters({"name"})
@Test
public void myTest(String param1){
}

In my external parameter file, I might have spelled "nmae" instead of "name".

Of course, the test fails as it should (configuration failure), but there is no good evidence of what happened. I am wondering which one of the testng interfaces would
give me a clue that there was a parameter issue. I did look but unfortunately nothing jumped out at me. I already extend the TestListenerAdapter, so it would be great
if there was a way to extend a little more..

Any pointers would be appreciated !!

thanks
walter

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.