swiftrail 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e24f38ee1aae456dcb51651d88749efaddccd34333aedee76dbbc37324c9703
4
- data.tar.gz: da2b976feeea24bad0767c2057ec9c21d5cf0c8add818a05e84ecabd590fc56f
3
+ metadata.gz: 24b9beb85d5c05e2b80e40dc6e5cfcc29c7d24571162d5003fb69f8bbb681937
4
+ data.tar.gz: 717bd96b5e4a2fd1b26e7d8a8e4c47da06aa297cd4fb41bef39826531cfe0189
5
5
  SHA512:
6
- metadata.gz: 2acd8bcf1b0dd12fb3b979884da1ba12d8c19a5d0759ae926ef5c5b10acca8e8886eedee665e8604bb2e06a906c09b4eba59ddbf679a412ce04f2ad1cca5f63d
7
- data.tar.gz: 30559bb2c5c062c575c3865f52893f8cf3732f2beaf9edf102763bdeb7fde64682bf9298dabadfb9af9d160b6e0efdfce4185fdc62ffb17f4893fdca526fd758
6
+ metadata.gz: ca865e1bd7b0174b409bdbecd6d285e201fd38e0c7ca63444842dacf169be5477fe66df85db5dcb67adba7e3d2060df8fef546619f02e5ad8c426db6fedba52f
7
+ data.tar.gz: 2a58d682fd847f8335a051998054198916d4e2694d3e9d66ce38097eb8703fb557ab1857aa1186802a41ff5203093f31e55f51b984f99c87538abf8dcd936202
data/README.md CHANGED
@@ -20,16 +20,13 @@ $ bundle
20
20
  ### Options
21
21
 
22
22
  Mandatory options for all of the commands are
23
-
23
+
24
24
  - `--test_classes=''` - regex for the path to swift tests
25
25
  - `--test_rail_username=''` - username for TestRail account
26
26
  - `--test_rail_password=''` - password for TestRail account
27
27
  - `--test_rail_url=''` - url for TestRail account
28
28
  - `--run_id=''` - run_id for which you want to run the command
29
29
 
30
- When running report you additionaly have to pass location of the test_reports
31
- - `--test-reports=''`
32
-
33
30
  ### Marking test cases
34
31
 
35
32
  In your `swift` projects you can mark any test class or specific test with any number of TestRail test cases. To mark them
@@ -67,14 +64,25 @@ class MyOtherTests: XCTestCase {
67
64
  ```
68
65
  ### Report
69
66
 
67
+ When running report you additionaly have to pass location of the test_reports, and if you want strict mode
68
+ - `--test-reports=''`
69
+ - `--strict` (default is `false`)
70
+
70
71
  To be able to report the results of the tests, you need to first generate xml junit reports. Once you have those, running
71
72
  ```
72
73
  swiftrail report --test-reports='path/to/test/reports' --run_id:123 (all the other options should also be included)
73
74
  ```
74
75
  will report the results to TestRail. Dependent on success/failure the tests on TestRail will be marked accordingly.
75
76
 
77
+
78
+ If the strict mode is enabled, the upload will fail if you have test cases that are not present in the test run.
79
+
76
80
  ### Coverage
77
81
 
82
+ When running coverage you additionaly can pass output folder, where the report will be generated (if not passed it will print out to terminal)
83
+ - `--output_folder=''`
84
+
85
+
78
86
  Coverage report will give you the percentage of test cases covered by your ui/unit/... tests.
79
87
 
80
88
  ```
@@ -83,6 +91,9 @@ swiftrail coverage --run_id:123 (all the other options should also be included)
83
91
 
84
92
  ### Lint
85
93
 
94
+ When running lint you additionaly can pass output folder, where the report will be generated (if not passed it will print out to terminal)
95
+ - `--output_folder=''`
96
+
86
97
  Lint will give you outadet case_ids that you have marked on your ui/unit tests, but no longer exist as test cases on TestRail.
87
98
 
88
99
  ```
data/lib/swiftrail/cli.rb CHANGED
@@ -21,6 +21,7 @@ module Swiftrail
21
21
 
22
22
  desc 'report', 'Reports success/failure to test rail, based on the results of your tests'
23
23
  method_option :test_reports, type: :string, aliases: '-reports', default: defaults['reports'], desc: 'Regex to match your junit report files.'
24
+ method_option :strict, type: :boolean, aliases: '-strict', default: defaults['reports'], desc: 'Fail if there you are trying to report missing test case id'
24
25
  def report
25
26
  if swiftrail_reporter.report_results(options[:run_id])
26
27
  puts 'Successfully reported the results'
@@ -60,7 +61,8 @@ module Swiftrail
60
61
  [options['test_classes']],
61
62
  options['test_rail_username'],
62
63
  options['test_rail_password'],
63
- options['test_rail_url']
64
+ options['test_rail_url'],
65
+ options['strict']
64
66
  )
65
67
  end
66
68
 
@@ -18,6 +18,7 @@ module Swiftrail
18
18
  def base_defaults
19
19
  {
20
20
  reports: '',
21
+ strict: false,
21
22
  test_classes: '',
22
23
  test_rail_username: '',
23
24
  test_rail_password: '',
@@ -42,7 +42,7 @@ module Swiftrail
42
42
  end
43
43
 
44
44
  def cases_regex
45
- %r{(//\s*TESTRAIL\s*([(C(0-9)*)|\s|,]*)$\s*)*(func |class )\s*(\w*)\s*(\(\)|:\s*XCTestCase)}im
45
+ %r{(//\s*TESTRAIL\s*([(C(0-9)*)|\s|,]*)$\s*)*^[\w ]*(func |class )\s*(\w*)\s*(\(\)|:\s*XCTestCase)}im
46
46
  end
47
47
 
48
48
  def sanitize(case_ids)
@@ -1,16 +1,18 @@
1
1
  module Swiftrail
2
2
  module Testrail
3
3
  module Api
4
- TestRailTest = Struct.new(:case_id, :id, :title) do
4
+ TestRailTest = Struct.new(:case_id, :id, :title, :automated) do
5
5
  def self.from_json(json)
6
- TestRailTest.new(json['case_id'], json['id'], json['title'])
6
+ automated = json['custom_automated'] == 3 || json['custom_automated'] == 4
7
+ TestRailTest.new(json['case_id'], json['id'], json['title'], automated)
7
8
  end
8
9
 
9
10
  def to_json(*_args)
10
11
  {
11
12
  id: id,
12
13
  case_id: case_id,
13
- title: title
14
+ title: title,
15
+ automated: automated
14
16
  }
15
17
  end
16
18
  end
@@ -6,30 +6,33 @@ require 'swiftrail/testrail/api/client'
6
6
  module Swiftrail
7
7
  module Testrail
8
8
  class Reporter
9
- def initialize(test_report_patterns, tests_patterns, test_rail_username, test_rail_password, test_rail_base_url)
9
+ def initialize(test_report_patterns, tests_patterns, test_rail_username, test_rail_password, test_rail_base_url, strict)
10
10
  @test_report_patterns = test_report_patterns
11
11
  @tests_patterns = tests_patterns
12
12
  @test_rail_username = test_rail_username
13
13
  @test_rail_password = test_rail_password
14
14
  @test_rail_base_url = test_rail_base_url
15
+ @strict = strict
15
16
  end
16
17
 
17
18
  def report_results(run_id)
18
- test_rail_client(run_id).publish_results(assembler(swift_test_parser.parse, junit_parser.parse).assemble)
19
+ test_rail_client(run_id).publish_results(purge(assembler(swift_test_parser.parse, junit_parser.parse).assemble, run_id))
19
20
  end
20
21
 
21
22
  private
22
23
 
23
- attr_reader :test_report_patterns, :tests_patterns, :test_rail_username, :test_rail_password, :test_rail_base_url
24
-
25
- def test_rail_client(run_id)
26
- Api::Client.new(test_rail_base_url, test_rail_username, test_rail_password, run_id)
27
- end
24
+ attr_reader :test_report_patterns, :tests_patterns, :test_rail_username, :test_rail_password, :test_rail_base_url, :strict
28
25
 
29
26
  def assembler(swift_tests, junit_test_suites)
30
27
  Assembler.new(swift_tests, junit_test_suites)
31
28
  end
32
29
 
30
+ def purge(test_cases, run_id)
31
+ test_cases.select do |test_case|
32
+ !strict || test_rail_test_cases(run_id).include?(test_case.case_id)
33
+ end
34
+ end
35
+
33
36
  def swift_test_parser
34
37
  Swiftrail::Swift::Parser.new(tests_patterns)
35
38
  end
@@ -37,6 +40,15 @@ module Swiftrail
37
40
  def junit_parser
38
41
  Swiftrail::Junit::Parser.new(test_report_patterns)
39
42
  end
43
+
44
+ def test_rail_test_cases(run_id)
45
+ @test_cases ||= test_rail_client(run_id).all_tests.map(&:case_id).map(&:to_s)
46
+ end
47
+
48
+ def test_rail_client(run_id)
49
+ Api::Client.new(test_rail_base_url, test_rail_username, test_rail_password, run_id)
50
+ end
51
+
40
52
  end
41
53
  end
42
54
  end
@@ -1,3 +1,3 @@
1
1
  module Swiftrail
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slavko Krucaj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri