sentry-unity
sentry-unity copied to clipboard
SentryInitialization.Init is always called in tests
SentryInitialization.Init
is called even for the simplest test because of RuntimeInitializeOnLoadMethod
attribute.
public void AssertPass()
=> Assert.Pass();
I encountered some not expected side effects while I was writing tests for UnityEventProcessor
.
Not sure how we can skip it just for tests. Doesn't look like there's compilation directive set when compiling for tests which makes sense since you might just run tests on a normal build.
We could disable the SDK selectively for those tests where we Initialize the SDK as part of the test by loading and disabling the ScriptableOptions within the editor?
Hmm, why is it [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
? Looks like something called multiple times even during normal runtime (regardless of tests)? Maybe we should instead use another event, for example this one sounds about right: AfterAssembliesLoaded
I think think this was due to AfterAssembliesLoaded
and BeforeSplashScreen
not being called in the Editor.
But since the Initialization now compiles with the game and we now have access to precompile directives we should rethink this.
Disabling self-initialization during tests with this If individual test classes are supposed to be executed with self-initialization disabled they should inherit from this.