Class: MutationTester::Core
- Inherits:
-
Object
- Object
- MutationTester::Core
- Defined in:
- lib/mutation_tester/core.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#mutations ⇒ Object
readonly
Returns the value of attribute mutations.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
-
#spec_file ⇒ Object
readonly
Returns the value of attribute spec_file.
Instance Method Summary collapse
-
#initialize(source_file, spec_file, config = MutationTester.configuration) ⇒ Core
constructor
A new instance of Core.
- #interrupted? ⇒ Boolean
- #mutation_score ⇒ Object
- #run ⇒ Object
- #threshold_met? ⇒ Boolean
Constructor Details
#initialize(source_file, spec_file, config = MutationTester.configuration) ⇒ Core
Returns a new instance of Core.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mutation_tester/core.rb', line 7 def initialize(source_file, spec_file, config = MutationTester.configuration) @source_file = File.(source_file) @spec_file = File.(spec_file) @config = config @mutations = [] @results = [] @parse_failed = false MutationRunner.recover_in_place_backup(@source_file) @original_content = File.read(@source_file) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/mutation_tester/core.rb', line 5 def config @config end |
#mutations ⇒ Object (readonly)
Returns the value of attribute mutations.
5 6 7 |
# File 'lib/mutation_tester/core.rb', line 5 def mutations @mutations end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
5 6 7 |
# File 'lib/mutation_tester/core.rb', line 5 def results @results end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
5 6 7 |
# File 'lib/mutation_tester/core.rb', line 5 def source_file @source_file end |
#spec_file ⇒ Object (readonly)
Returns the value of attribute spec_file.
5 6 7 |
# File 'lib/mutation_tester/core.rb', line 5 def spec_file @spec_file end |
Instance Method Details
#interrupted? ⇒ Boolean
42 43 44 45 46 |
# File 'lib/mutation_tester/core.rb', line 42 def interrupted? @config.fail_fast && @results.size < @mutations.size && @results.any? { |result| result[:status] == :survived } end |
#mutation_score ⇒ Object
48 49 50 |
# File 'lib/mutation_tester/core.rb', line 48 def mutation_score Reporters::BaseReporter.score(@results) end |
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mutation_tester/core.rb', line 18 def run print_header return false unless run_original_tests generate_mutations return false if @parse_failed if @mutations.empty? puts Rainbow("\n✓ No mutations were generated for this file; nothing to test.").green return true end return false unless shadow_environment_reliable? run_mutations generate_reports return report_interruption if interrupted? check_threshold ensure @mutation_runner&.cleanup_shadow_workspaces ForkRunner.shutdown_all end |
#threshold_met? ⇒ Boolean
52 53 54 55 56 |
# File 'lib/mutation_tester/core.rb', line 52 def threshold_met? return true unless @config.fail_on_threshold mutation_score >= @config.minimum_score end |