Skip to content

Running under scoverage changes a != null check to call .equals(null)? #680

Open
@josephlbarnett

Description

@josephlbarnett

Describe the bug

See minimal reproducer here: https://github.com/josephlbarnett/testscoverageissue

run with mvn verify -> test passes
run with mvn scoverage:report -> test fails with:

[ERROR] com.example.WrapperTest.testEquals -- Time elapsed: 0.142 s <<< FAILURE!
java.lang.NullPointerException
	at com.example.Wrapper.equals(Wrapper.scala:13)
	at com.example.Wrapper.equals(Wrapper.scala:21)
	at com.example.WrapperTest.testEquals(WrapperTest.scala:11)
[snip]

If I add an obj == null || to line 13 of Wrapper.scala it works, but would not expect running under coverage to change behavior like this?

(also reproduced this under sbt in addition to maven)

Expected behavior

Test pass or fail should not be affected by being run under scoverage

What build tool are you using?

Maven

Version of scoverage

2.0.6 version of the maven plugin, which looks like it uses 2.2.1 of scalac-scoverage-plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions