Class: FlakyTestTracker::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/flaky_test_tracker/resolver.rb

Overview

Test resolver.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pretend:, storage:, reporter:, verbose:) ⇒ Resolver

Returns a new instance of Resolver.



12
13
14
15
16
17
# File 'lib/flaky_test_tracker/resolver.rb', line 12

def initialize(pretend:, storage:, reporter:, verbose:)
  @pretend = pretend
  @storage = storage
  @reporter = reporter
  @verbose = verbose
end

Instance Attribute Details

#pretendBoolean

Run but do not make any changes on the #storage

Returns:

  • (Boolean)

    the current value of pretend



9
10
11
# File 'lib/flaky_test_tracker/resolver.rb', line 9

def pretend
  @pretend
end

#reporter#tracked_tests #resolved_tests

Returns the current value of reporter.

Returns:

  • (#tracked_tests #resolved_tests)

    the current value of reporter



9
10
11
# File 'lib/flaky_test_tracker/resolver.rb', line 9

def reporter
  @reporter
end

#storage#all #create #update #delete

Returns the current value of storage.

Returns:

  • (#all #create #update #delete)

    the current value of storage



9
10
11
# File 'lib/flaky_test_tracker/resolver.rb', line 9

def storage
  @storage
end

#verboseBoolean

Returns the current value of verbose.

Returns:

  • (Boolean)

    the current value of verbose



9
10
11
# File 'lib/flaky_test_tracker/resolver.rb', line 9

def verbose
  @verbose
end

Instance Method Details

#resolve {|test| ... } ⇒ Array<Test>

Resolve tests by updating test "resolved_at" attribute to the current time on the storage.

Yields:

  • (test)

    Call block with each Test with attribute "resolved_at" equals to nil on the #storage and resolve those when block returns a truthy value.

Returns:

  • (Array<Test>)

    resolved tests.



23
24
25
26
27
28
# File 'lib/flaky_test_tracker/resolver.rb', line 23

def resolve(&block)
  resolved_tests = select_tests(&block).map { |test| resolve_test(test) }
  reporter.resolved_tests(tests: resolved_tests)
  puts "\n[FlakyTestTracker][Resolver] #{resolved_tests.count} test(s) resolved" if verbose
  resolved_tests
end