jvliwanag
jvliwanag

Reputation: 1598

How to check if sbt in test context?

How can an application tell if it's running under an 'sbt test' context? Is there a system property that can be checked?

Upvotes: 7

Views: 826

Answers (1)

0__
0__

Reputation: 67280

There are probably different ways. I found the following works:

testOptions += Tests.Setup(_ => sys.props("testing") = "true")

And then you can just test for sys.props.get("testing") in your class.

Upvotes: 10

Related Questions