shivadorepally / junitparams

Automatically exported from code.google.com/p/junitparams
0 stars 0 forks source link

It should be possible to access the parameterized values via a Rule #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

i was wondering if it is possible to access the parameters via a rule. 
Backround: we are using parameterized testcases for ui testing with selenium. 
For each failure a screenshot is taken. To match a screenshot with a testcase 
we do also need the paramters in the name of the screenshot file, for 
identification. So, is it possible to access the parameters in a JUnit rule? 

cheers,
Andy

Original issue reported on code.google.com by andreas....@gmail.com on 31 Jan 2012 at 8:41

GoogleCodeExporter commented 8 years ago
I cannot get why you need a rule for this. You have the params' values in the 
test itself... Or are you taking the snapshot from outside of the test?

In general - yes, you can. This rule will print out all params:
public static class TestParams implements TestRule {
        @Override
        public Statement apply(Statement base, Description description) {
            System.out.println(((InvokeParameterisedMethod) base).getParamsAsString());
            return base;
        }
    }

Original comment by lipinski...@gmail.com on 10 Feb 2012 at 10:53

GoogleCodeExporter commented 8 years ago
Creating the screenshots is done with a JUnit Rule, so i do not have access to 
the testcase. And thanks for your hint, i will try it.

Original comment by andreas....@gmail.com on 10 Feb 2012 at 11:04