Snooz82 / robotframework-datadriver

Library to provide Data-Driven testing with CSV tables to Robot Framework
Apache License 2.0
131 stars 37 forks source link

Workaround for test suite filtering by tag #7

Closed lethall closed 5 years ago

lethall commented 5 years ago

Unfortunately there is no api to intercept the command line filter. This workaround provides a simple way to get the job done. Since the tags are determined solely from the command line args, there is no additional need to rely on the robot API. The only side-effect is the existence of a hardwired variable defined in the run environment (named "includeTag") which may not serve any other purpose.

lethall commented 5 years ago

Understood.

The specifics for our need is that everything has to be driven from the spreadsheet. The .robot files will only be the glue between the workbook + sheet name and the subdirectory to control the name of the suite. We run these in the cloud with the specs coming from a designated git repo location.

Our remote test agent is using --include and --exclude; but if a tag is specified in that way, the run_cli examines the suites and detects that there are no suites with the tags, so the run stops before DataDriver gets called.

I think I see what you're thinking about doing with using Force Tags with the --include and moving that logic into DataDriver._start_suite so I may take a stab at doing that.

lethall commented 5 years ago

No hardwired variable names now, and using the library initializer to specify the tags to include. Moved the filter to DataDriver. Fixed the doc to illustrate two tags. The actual example Robot file has doc to illustrate a single tag.

Though I see that adding Force Tags does get around the premature end when --include is used, I still couldn't find a way to get the tags used by the visitor Filter.

lethall commented 5 years ago

It's not clear to me how your implementation is to be used, as you mentioned both the ability to use the --include command line and the include= library initializer. Because I don't see any new commits, I assume that you haven't pushed your implementation yet... when will your changes be available?

Further, for our case the tags are often names, not numbers, so are the "AND" and "OR" boolean operators in the example "1AND2OR3"? If so, what is the exact syntax for applying booleans to the library initializer when the tags are not numbers?

Snooz82 commented 5 years ago

Now it is pushed. Also to Pypi. New Version is 0.3.1

See here how to use TagPattern. http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tag-patterns

Tags that are Strings are possible. Like thisANDtheseORWhatEver

I added also some documentation.

You can also write your own DataReader. In Your case i would recommend to have a look to generic_csv_reader.py

Please test it and give feedback!!

Thanks for your contribution!!!