Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by wadazu · Aug 09, 2018 at 04:11 PM · reference assemblies

Missing reference between 'Assembly-CSharp' and 'Tests' assembly, created with Assembly Definition

I try to create some NUnit-Tests for my HoloLens-Unity project. To test in PlayMode, I added a "Tests" folder with a Assembly Definition file:

 {
     "name": "Tests",
     "optionalUnityReferences": [
         "TestAssemblies"
     ]
 }

This works fine and I can run some empty functions with Test and UnityTest attribute. Then, I created a MonoBehaviour in my "Assembly-CSharp" project. But now, it isn't possible to add/create a reference between my "Tests" project and "Assembly-CSharp" project.

I found no way in VS17 and Unity to add this reference. When I add

 "references": [ "Assembly-CSharp" ],

directly to my Assembly Definition file, there appears a error in Unity "Assembly has reference to non-existent assembly 'Assembly-CSharp' (Assets/Tests/Tests.asmdef)".

Unity version: Unity 2018.1.6f1

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ChrisNavarre · Sep 26, 2018 at 10:28 AM 0
Share

Also experiencing this issue as well. In visual studio I can go into project dependencies for the Test project and add in "Depends on Assembly-CSharp" but in unity. I keep getting error messages like

 Assets/Scripts/Zenject/Tests/SaveUnitTests.cs(3,22): error CS0234: The type or namespace name `Characters' does not exist in the namespace `ChrisTutorials'. Are you missing an assembly reference?
 

Been trying to figure this out for Zenject or just NUnit alone. Can't seem to get classes I've writen to be usable in the Unit tests.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by bradford · Dec 31, 2018 at 04:32 PM

Hey, not sure if you ever figured this out but I encountered similar problems and was able to document a solution here:

https://stackoverflow.com/questions/53845650/in-unity3d-test-scripts-how-do-i-call-a-static-function-from-another-class

To briefly elaborate, most of the code that you write in unity3d is stored in an assembly called Assembly-csharp.dll. For reasons that are beyond me, Unity doesn't let you reference this assembly from test code. However, you can make an assembly definition for your code under test, and reference that instead. Furthermore, if you are using editmode tests (it doesn't look like you are), you'll need to put your tests underneath a folder called 'Editor'.

I can't explain what's going on behind the scenes. I'm personally unhappy that Unity forced me to go through these steps and it makes me think that testrunner is a half baked feature that's not yet ready for public consumption. The lack of engagement in this and other forums make me question my commitment to Unity.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

89 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to and where to add external .dll file in unity 1 Answer

Unity Doesn't Recognize an Assembly Reference? 1 Answer

Add reference gives "invalid 'assembly' metadata" 0 Answers

How to keep helper classes with missing reference in project? 0 Answers

Swap code with DLL, component reference lost 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges