Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Coverage.setup

(?lines: bool, ?branches: bool, ?methods: bool, ?eval: bool) -> nil
(oneshot_lines: bool, ?branches: bool, ?methods: bool, ?eval: bool) -> nil
(:all) -> nil
Coverage.setup → nil
Coverage.setup(type) → nil
Coverage.setup(lines: false, branches: false, methods: false, eval: false, oneshot_lines: false) → nil

Performs setup for coverage measurement, but does not start coverage measurement. To start coverage measurement, use Coverage.resume.

To perform both setup and start coverage measurement, Coverage.start can be used.

With argument type given and type is symbol :all, enables all types of coverage (lines, branches, methods, and eval).

Keyword arguments or hash type can be given with each of the following keys:

  • lines: Enables line coverage that records the number of times each line was executed. If lines is enabled, oneshot_lines cannot be enabled. See Lines Coverage.

  • branches: Enables branch coverage that records the number of times each branch in each conditional was executed. See Branches Coverage.

  • methods: Enables method coverage that records the number of times each method was exectued. See Methods Coverage.

  • eval: Enables coverage for evaluations (e.g. Kernel#eval, Module#class_eval). See Eval Coverage.

See also .running? .start .resume .state also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1