Status: New Owner: ---- Labels: Type-Enhancement Priority-Medium
New issue 565 by bryan.oakley: support custom filters for determining if a test should run
http://code.google.com/p/robotframework/issues/detail?id=565 I would like to be able to write a custom filter in python for determining whether a test should run or not. I think this might be fairly trivial to implement at the test suite level. For example, BaseTestSuite.filter() looks like this presently: def filter(...): self.filter_by_names(suites, tests) self.filter_by_tags(includes, excludes) I propose it be changed to something like this: def filter(...): self.filter_by_names(suites, tests) self.filter_by_tags(includes, excludes) if self.custom_filter is not None: self.custom_filter() ... and that a method SetCustomFilter be added to BaseTestSuite. We have a custom front-end to jybot, and just that small change might let me write something like: def myFilter(self, suite): # all kinds of clever code! BaseTestSuite.SetCustomFilter(myFilter) The reason is this: some of my users have a system where application features can be turned on or off via a config file (that must be fetched over the wire, to add an additional complication!). This file might have something like "feature-a: enabled; feature-b: disabled". They then want to feed this config file to jybot so that it can exclude tests for any features that are disabled. Of course, I can write a pre-processor that parses the config file, computes a command line with a --include= or --exclude= argument for every feature, but these features could run into the hundreds and I'm afraid we'll hit limitations with the number of command line arguments we can send to jybot. Another use would be from ride -- I want to modify our test runner plugin so users can select which tests to run. Right now they have to add a temporary tag, then tell robot to only run a test with that tag. That's sloppy. Instead, I want to give them a checklist, they can check all the tests they want, I can write that to a file or send it over a pipe, and my custom filter can read it and Do The Right Thing. Even better might be to generalize the filter mechanism, so that the highest level filter looks like: class BaseTestSuite: def __init__(...): # default filters self.RegisterFilter(self.filter_by_name) self.RegisterFilter(self.filter-by_tag) def filter(...): for filter in self._filters: filter(...) (this is all based on just a brief glance through the existing filtering mechanism -- maybe there's an even easier way to accomplish this that I don't know about. I'm open to suggestions)
