If you were previously linking stories directly to tests, and you would like to begin using requirements, use req_df_from_tests() and req_df_to_yaml() to create a requirements YAML file that parses requirement descriptions from test names. Then use stories_replace_tests_with_reqs() to edit your stories YAML to reference the newly created requirements.

req_df_from_tests(test_df)

req_df_to_yaml(req_df, out_file)

stories_replace_tests_with_reqs(stories_file, req_spec)

Arguments

test_df

Tibble of tests results, as returned from parse_testthat_list_reporter() or parse_golang_test_json()

req_df

Tibble of requirements, as returned from req_df_from_tests().

out_file

Path to write requirements YAML file to.

stories_file

Path to write stories YAML file that will be modified on disk.

req_spec

Tibble of requirements, as returned from req_df_from_tests().

Details

Note that these functions are designed to help you convert a repo that previously did not use requirements into one that does. They are not meant for continued use after that. Going forward, requirements should be specified in the requirements YAML file, instead of being pull through from test names

Functions

  • req_df_from_tests(): Create new requirements tibble from test results tibble.

  • req_df_to_yaml(): Write requirements YAML file from requirements tibble.

  • stories_replace_tests_with_reqs(): Modify existing stories YAML to reference new requirements instead of tests.

Examples

if (FALSE) {

# run your test suite to get a tibble of test names and IDs
test_res <- mrgvalprep::parse_testthat_list_reporter(
  devtools::test(Reporter = testthat::ListReporter)
)

# create requirements tibble and write to new YAML
req_df <- req_df_from_tests(test_res)
req_df_to_yaml(req_df, "inst/validation/requirements.yaml")

# edit existing stories YAML
stories_replace_tests_with_reqs("inst/validation/stories.yaml", req_df)

}