Assembly definition can't resolve namespaces from external packages

Viewed 1266

I created a new project with Unity. In the project settings I set the field Root namespace to Assets.

I'm using the external package Entitas-Redux by installing it via Git url. In the code I will then have access to additional classes from the Entitas-Redux namespace.

I want to create unit tests for my scripts located in the Scripts folder, so I created a "Tests Assembly Folder" from the context menu. The current folder structure is

enter image description here

I get a warning that it couldn't find any test. So I have to tell the assembly definition ScriptTests where to search for the scripts.

That's why I added another assembly definition

enter image description here

Now I can associate the scripts assembly definition with the scripttests assembly definition. The problem is that the scripts assembly definition can't find the external package namespace anymore

enter image description here

How to fix this?

Should I remove the scripts assembly definition and add the scripts located in the scripts folder with another approach?

1 Answers

Your test asm can only test scripts that are in asm themselves.

I would suggest to move the test folder up to Assets so there is no collusion.

Then, looking at your hierarchy, you could add an asm to Sources. At that point if anything in Sources is using code outside of it, you'll have to add the assembly reference to the asm for that module.

Finally, you add Sources.asm to the test asm and your code is visible to the test.

Related