{"action":"created","issue":{"url":"https://api.github.com/repos/enkessler/cql/issues/8","labels_url":"https://api.github.com/repos/enkessler/cql/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/enkessler/cql/issues/8/comments","events_url":"https://api.github.com/repos/enkessler/cql/issues/8/events","html_url":"https://github.com/enkessler/cql/issues/8","id":116625779,"number":8,"title":"How to query on number of total tests, and number of wipped tests?","user":{"login":"cartoloupe","id":4593934,"avatar_url":"https://avatars.githubusercontent.com/u/4593934?v=3","gravatar_id":"","url":"https://api.github.com/users/cartoloupe","html_url":"https://github.com/cartoloupe","followers_url":"https://api.github.com/users/cartoloupe/followers","following_url":"https://api.github.com/users/cartoloupe/following{/other_user}","gists_url":"https://api.github.com/users/cartoloupe/gists{/gist_id}","starred_url":"https://api.github.com/users/cartoloupe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cartoloupe/subscriptions","organizations_url":"https://api.github.com/users/cartoloupe/orgs","repos_url":"https://api.github.com/users/cartoloupe/repos","events_url":"https://api.github.com/users/cartoloupe/events{/privacy}","received_events_url":"https://api.github.com/users/cartoloupe/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-12T19:46:25Z","updated_at":"2015-11-12T21:46:46Z","closed_at":"2015-11-12T20:38:04Z","body":"I read through the documentation, but could not find how to query for number of total tests and number of wipped tests."},"comment":{"url":"https://api.github.com/repos/enkessler/cql/issues/comments/156246158","html_url":"https://github.com/enkessler/cql/issues/8#issuecomment-156246158","issue_url":"https://api.github.com/repos/enkessler/cql/issues/8","id":156246158,"user":{"login":"enkessler","id":690565,"avatar_url":"https://avatars.githubusercontent.com/u/690565?v=3","gravatar_id":"","url":"https://api.github.com/users/enkessler","html_url":"https://github.com/enkessler","followers_url":"https://api.github.com/users/enkessler/followers","following_url":"https://api.github.com/users/enkessler/following{/other_user}","gists_url":"https://api.github.com/users/enkessler/gists{/gist_id}","starred_url":"https://api.github.com/users/enkessler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enkessler/subscriptions","organizations_url":"https://api.github.com/users/enkessler/orgs","repos_url":"https://api.github.com/users/enkessler/repos","events_url":"https://api.github.com/users/enkessler/events{/privacy}","received_events_url":"https://api.github.com/users/enkessler/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T21:46:46Z","updated_at":"2015-11-12T21:46:46Z","body":"For your test counting case, that query will only pick up a Scenario. If you want to find all of your tests, then you will want to include both types in your query. Like so:\r\n\r\n    total_tests = cql_repo.query do\r\n      select\r\n      from scenarios, outlines\r\n    end\r\n\r\n    puts \"total tests: #{total_tests.count}\"\r\n\r\nIf you further wanted to know about individual test executions, then you would need to break down the outlines into their rows:\r\n\r\n    total_tests = cql_repo.query do\r\n      select :self\r\n      as test_cases\r\n      from scenarios, outlines\r\n      transform :self => lambda { |test|\r\n                  if test.is_a?(CukeModeler::Outline)\r\n                    # Outlines are many test cases from one template\r\n                    test.examples.reduce(0) { |sum, example| sum += example.rows.count }\r\n                  else\r\n                    # Scenarios are just a single test case\r\n                    1\r\n                  end\r\n                }\r\n    end\r\n\r\n    puts \"total_tests: #{total_tests.collect { |result| result['test_cases'] }.reduce(:+)}\"\r\n\r\n\r\nFinally, be aware that #tags only return tags that are directly attached to the test. #all_tags is the method that you would want to use if you want to pick up tags that tests inherit from the Feature level as well.\r\n"}}