def main(): """ Usage: radish-test matches <match-configs>... [-b=<basedir> | --basedir=<basedir>] [--cover-min-percentage=<cover-min-percentage>] [--cover-show-missing] radish-test (-h | --help) radish-test (-v | --version) Arguments: match-configs configuration files of step matcher tests Commands: matches test if the step implementions actually match the expected sentences Options: -h --help show this screen -v --version show version -b=<basedir> --basedir=<basedir> set base dir from where the step.py and terrain.py will be loaded [default: $PWD/radish] --cover-min-percentage=<cover-min-percentage> minimum percentage of step coverage for tests to pass --cover-show-missing show steps which are not tested (C) Copyright by Timo Furrer <*****@*****.**> """ arguments = docopt("radish-test {0}\n{1}".format(__VERSION__, main.__doc__), version=__VERSION__) if arguments['matches']: return test_step_matches_configs(arguments['<match-configs>'], arguments['--basedir'], arguments['--cover-min-percentage'], arguments['--cover-show-missing'])
def test_no_steps_found(mocker, capsys): """ Test if basedir does not contain any Steps to test against """ # given mocker.patch('radish.testing.matches.load_modules') expected_returncode = 4 # when actual_returncode = matches.test_step_matches_configs(None, []) _, err = capsys.readouterr() # then assert actual_returncode == expected_returncode assert err == 'No step implementations found in [], thus doesn\'t make sense to continue'
def test_unreasonable_min_coverage(capsys): """ Test unreasonable minimum test coverage """ # given min_coverage = 101 expected_returncode = 3 # when actual_returncode = matches.test_step_matches_configs(None, [], min_coverage) _, err = capsys.readouterr() # then assert actual_returncode == expected_returncode assert err == 'You are a little cocky to think you can reach a minimum coverage of 101.00%\n'
def test_no_steps_found(mocker, capsys): """ Test if basedir does not contain any Steps to test against """ # given mocker.patch("radish.testing.matches.load_modules") expected_returncode = 4 # when actual_returncode = matches.test_step_matches_configs(None, []) _, err = capsys.readouterr() # then assert actual_returncode == expected_returncode assert ( err == "No step implementations found in [], thus doesn't make sense to continue" )
def test_unreasonable_min_coverage(capsys): """ Test unreasonable minimum test coverage """ # given min_coverage = 101 expected_returncode = 3 # when actual_returncode = matches.test_step_matches_configs(None, [], min_coverage) _, err = capsys.readouterr() # then assert actual_returncode == expected_returncode assert ( err == "You are a little cocky to think you can reach a minimum coverage of 101.00%\n" )
def test_empty_matches_config(mocker, capsys): """ Test empty matches config file """ # given expected_returncode = 5 fd, tmpfile = tempfile.mkstemp() os.close(fd) mocker.patch('radish.testing.matches.load_modules') steps_mock = mocker.patch('radish.testing.matches.StepRegistry.steps') steps_mock.return_value = [1, 2] # when actual_returncode = matches.test_step_matches_configs([tmpfile], []) out, _ = capsys.readouterr() # then assert actual_returncode == expected_returncode assert out == 'No sentences found in {0} to test against\n'.format(tmpfile)
def test_empty_matches_config(mocker, capsys): """ Test empty matches config file """ # given expected_returncode = 5 fd, tmpfile = tempfile.mkstemp() os.close(fd) mocker.patch("radish.testing.matches.load_modules") steps_mock = mocker.patch("radish.testing.matches.StepRegistry.steps") steps_mock.return_value = [1, 2] # when actual_returncode = matches.test_step_matches_configs([tmpfile], []) out, _ = capsys.readouterr() # then assert actual_returncode == expected_returncode assert out == "No sentences found in {0} to test against\n".format(tmpfile)
def main(): """ Usage: radish-test matches <match-configs>... [-b=<basedir> | --basedir=<basedir>...] [--cover-min-percentage=<cover-min-percentage>] [--cover-show-missing] radish-test (-h | --help) radish-test (-v | --version) Arguments: match-configs configuration files of step matcher tests Commands: matches test if the step implementations actually match the expected sentences Options: -h --help show this screen -v --version show version -b=<basedir> --basedir=<basedir>... set base dir from where the step.py and terrain.py will be loaded. [default: $PWD/radish] You can specify -b|--basedir multiple times or split multiple paths with a colon (:) similar to $PATH. All files will be imported. --cover-min-percentage=<cover-min-percentage> minimum percentage of step coverage for tests to pass --cover-show-missing show steps which are not tested (C) Copyright by Timo Furrer <*****@*****.**> """ arguments = docopt("radish-test {0}\n{1}".format(__VERSION__, main.__doc__), version=__VERSION__) if arguments["matches"]: return test_step_matches_configs( arguments["<match-configs>"], utils.flattened_basedirs(arguments["--basedir"]), arguments["--cover-min-percentage"], arguments["--cover-show-missing"], )
def main(): """ Usage: radish-test matches <match-configs>... [-b=<basedir> | --basedir=<basedir>...] [--cover-min-percentage=<cover-min-percentage>] [--cover-show-missing] radish-test (-h | --help) radish-test (-v | --version) Arguments: match-configs configuration files of step matcher tests Commands: matches test if the step implementations actually match the expected sentences Options: -h --help show this screen -v --version show version -b=<basedir> --basedir=<basedir>... set base dir from where the step.py and terrain.py will be loaded. [default: $PWD/radish] You can specify -b|--basedir multiple times or split multiple paths with a colon (:) similar to $PATH. All files will be imported. --cover-min-percentage=<cover-min-percentage> minimum percentage of step coverage for tests to pass --cover-show-missing show steps which are not tested (C) Copyright by Timo Furrer <*****@*****.**> """ arguments = docopt( "radish-test {0}\n{1}".format(__VERSION__, main.__doc__), version=__VERSION__ ) if arguments["matches"]: return test_step_matches_configs( arguments["<match-configs>"], utils.flattened_basedirs(arguments["--basedir"]), arguments["--cover-min-percentage"], arguments["--cover-show-missing"], )