Testing MonoBehaviours in a Package

Hi! I’m working on a package.
It has MonoBehaviour scripts in it.
I’m trying to test these MB scripts.
I decided to setup Test Scenes with certain states, load them during the Test, and to assert results.

  • I tried PlayMode Tests. To SceneManager.LoadScene and to assert results.
    The issue:
    Unity wants these Scenes to be added to BuildSettings.
    I cannot do this, because this is a package.

  • I tried EditorTests with EditorSceneManager.OpenScene
    The issue:

  • OpenScene* requires a path to a scene, and it cannot find my scene in Packages folder

  • Instead of scenes, I could Instantiate prefabs from my Tests folder. The issue: AssetDatabase cannot find assets in Packages folder.

The question!
How to setup Tests in a Package with several MonoBehaviours instantiated in a Scene-like or Prefab-like structure?

Forgive me if you’ve already explored this but Unity has a built in Testing framework: Introduction To Unity Unit Testing | Kodeco

Does this work for you? Not sure if being a package makes it not useable.

Hi PraetorBlue! Thanks.
Yes, I’m trying to apply Unity Testing framework to a Package.
For now, I’m gonna continue with PlayMode tests…
Maybe someone would come up with better approach to testing a package.