Scott Frazer
Scott Frazer

Reputation: 2185

How do I run some Scala code when the JVM starts?

The problem I have is that I need to do some System.properties modifications and checks when the application starts AND when tests start running.

How do get code to run basically as soon as the JVM can start running code? I tried a package object but I couldn't seem to get it to execute the code unless it was invoked.

Upvotes: 0

Views: 94

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170713

Just make all your test classes extend an abstract base class which calls the initialization code in the constructor.

Upvotes: 3

Related Questions