I put up a few small tests to cover data validation within a file. I'll be building off this project in Github with examples:
https://github.com/wbwarnerb/ts/tree/master/features
So far I've just got a few tests. The first is a test that verifies Data Files have been delivered and just makes sure they exist. It's look at the root of the drive for a few files. This can be modified easily. Here's the Scenario File:
Here's the Step Definition code:
Here's the Scenario:
Here's the Step Definition Code:
https://github.com/wbwarnerb/ts/tree/master/features
So far I've just got a few tests. The first is a test that verifies Data Files have been delivered and just makes sure they exist. It's look at the root of the drive for a few files. This can be modified easily. Here's the Scenario File:
Scenario Outline: Check that file existsGiven a file has come inThen the <datafile> is verified as being thereExamples:|datafile||setup.log||hamlet.txt |
Here's the Step Definition code:
The second test does a count on the lines in each file. It then assumes the user knows this count and validates that each file is the correct line count. Here's the code to accomplish it:Then /^the (.*) is verified as being there$/ do |datafile|assert File.exists?("/#{datafile}")end
Here's the Scenario:
Scenario Outline: Line Count ValidationGiven a file has come inThen the <datafile> and it's <linecount> are verifiedExamples:|datafile|linecount||setup.log|10 ||hamlet.txt |4463 |
Here's the Step Definition Code:
Then /^the (.*) and it's (.*) are verified$/ do |datafile, linecount|count = 0File.open("/#{datafile}") {|f| count = f.read.count("\n") } == "#{linecount}"puts "The line count for '#{datafile}' is:"puts countend
No comments:
Post a Comment