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
0
Question by tmurraysdca70 · May 06, 2020 at 09:29 PM · jsontesting

TextAsset connected for app but not for TestRunner

In my JsonReader.cs script, I have the following: // file to read lessons from public TextAsset jsonFile;

In the Unity editor, I have created a file: Assets/Resources/lesson-test.json, and dragged it to the jsonFile field of the script.

In my app, the following works fine: // file to read lessons from public TextAsset jsonFile;

  void Start()
     {
         Assert.IsNotNull(jsonFile);
     }

but from Test Runner, this fails:

         [UnityTest]
         public IEnumerator TestStart()
         {
             Assert.Pass();
 
             yield return null;
         }

 TestStart (0.023s)
 ---
 Unhandled log message: '[Exception] AssertionException: Assertion failure. Value was Null
 Expected: Value was not Null'. Use UnityEngine.TestTools.LogAssert.Expect
 ---
 UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
 UnityEngine.Assertions.Assert.IsNotNull (UnityEngine.Object value, System.String message) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
 UnityEngine.Assertions.Assert.IsNotNull[T] (T value, System.String message) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
 UnityEngine.Assertions.Assert.IsNotNull[T] (T value) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
 JsonReader.Start () (at Assets/Scripts/JsonReader.cs:41)
 ---
 AssertionException: Assertion failure. Value was Null
 Expected: Value was not Null

How do I make this TextAsset connect properly when running TestRunner?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tmurraysdca70 · May 06, 2020 at 09:30 PM

I can't figure out how to edit my post, this should have been in a code block: // file to read lessons from public TextAsset jsonFile;

Comment
Add comment · Show 1 · 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
avatar image tmurraysdca70 · May 06, 2020 at 09:45 PM 0
Share

I figured it out:

 I figured it out:
 
 [SetUp]
 public void Setup()
 {
     jsonReader = new GameObject().AddComponent<JsonReader>();
     jsonReader.jsonFile = Resources.Load("lesson-test") as TextAsset;
 }
 
 // Verify class exists
 [Test]
 public void JsonReaderClassExists()
 {
     Assert.IsNotNull(jsonReader);
     Assert.IsNotNull(jsonReader.jsonFile);
 }

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

126 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 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 find if WWW Post Request is succesful? 2 Answers

WWW.text string not correct? 2 Answers

converting excel to json: reading problem when file too large 0 Answers

Getting data out of Dictionary 0 Answers

Accessing a Json FILE and using it to set variables 2 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