Hello,
I am new with Unity test framework and have encountered a problem.
I want to access a script attached to a GameObject in the scene that I load in the beginning of the test.
The problem occurs in the bolded areas: The type or namespace name ‘****’ could not be found (are you missing a using directive or an assembly reference?
How can I access methods in script attached to a gameObject in a scene I open with a test?
Thanks for the help:)
Code:
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using *name of my assembly
namespace Tests
{
public class Test1
{
private GameObject otherGameObject;
private MyScriptName myScriptName;
[UnityTest]
public IEnumerator Test1WithEnumeratorPasses()
{
SceneManager.LoadScene(“NameOfMyScene”);
yield return new WaitForSecondsRealtime(5);
otherGameObject = GameObject.Find(“GameObjectWithScript”);
myScriptName = otherGameObject.GetComponent<MyScriptName>();
yield return null;
}
}
}