Raidil142
Raidil142

Reputation: 137

Is there a way to cover all permutations of parameters in a test

I am writing a Selenium test to validate an input form on my web page. I would like to cover all combinations of input data, but I would not like to write a separate test for each. Right now, I'm using an excel spreadsheet as a data source and I have the combinations listed as each row.

I was hoping there would be a way to cover all the cases without needing to use the excel file or write a separate test for each case. Is there anything that can help with this?

Upvotes: 1

Views: 2571

Answers (2)

StriplingWarrior
StriplingWarrior

Reputation: 156653

If you can come up with each possibility you want to test for each parameter, then you can do a quick cross-join using multiple from statements in LINQ syntax to come up with every combination of those possibilities.

You may also want to look at Pex. It can analyze your class and generate test methods to test every possible code path. It can be really useful for finding those corner cases that you might not have thought of on your own. Of course, this is only useful if you've written the class in a unit-testable manner. It may not help if your web page's form isn't backed by an MVC action or something of that sort.

Upvotes: 2

Random Dev
Random Dev

Reputation: 52290

do you just need a way to get all combinations to values? You can do this with linq and various other techniques - see this questions as an example

So generate all input-combinations for your method and then just write a Unittest (potential very long running) in mstest or whatever to check each one.

Upvotes: 1

Related Questions