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 /
  • Help Room /
avatar image
0
Question by bsteenwi · Mar 18, 2016 at 05:20 PM · editormonodeveloptestingmacosxmissingmethodexception

Unit test: PlayerPrefs, Attempted to access a missing method.

Hi,

I'm writing a unit test in the editor of monodeveloper. An object in this class uses an PlayerPrefs.HasKey call and works fine in game. However, the unit test gives an System.MissingMethodException when it tries to acces this HasKey method.

My code:

 using UnityEngine;
 using System.IO;
 using System.Net;
 using System;
 using SimpleJSON;
 using Network;
 using System.Collections.Generic;
 using EncryptString;
 using System.Text;
 
 
 /// <summary>
 /// Session manager holds information about the current session and is responsable for getting it from the network manager.
 /// </summary>
 /// 
 [Serializable]
 public class SessionManager
 {
     INetworkManager network_manager;
 
     private Session session;
     private GUIStyle guiStyle;
 
     public SessionManager(INetworkManager network_manager){
         this.network_manager = network_manager;
     }
 
     /// <summary>
     /// Method to request a login
     /// </summary>
     public void login (string username)
     {
         if (PlayerPrefs.HasKey ("Authorization")) {
 
 ....

My test:

 using NUnit.Framework;
 using Network;
 using Network.IO;
 using System.Net;
 using UnityEngine;
 using System;
 
 [TestFixture()]
 public class TestSessionManager
 {
 
     [Test()]
     public void TestLogin ()
     {
         //delete all player prefs
         //PlayerPrefs.DeleteAll ();
         //initialize networkstub
         NetworkStub stub = new NetworkStub ();
         SessionManager manager = new SessionManager (stub);
         manager.login ("john");
 
 ...

How can i solve this error? I'm getting the same specific error while doing this:

     [Test()]
     public void test(){
         Debug.Log ("test");
     }

 System.MissingMethodException : Attempted to access a missing method.
 Stack trace:
   at (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,string,UnityEngine.Object)
   at UnityEngine.DebugLogHandler.LogFormat (LogType logType, UnityEngine.Object context, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0 
   at UnityEngine.Logger.Log (LogType logType, System.Object message) [0x00000] in <filename unknown>:0 
   at UnityEngine.Debug.Log (System.Object message) [0x00000] in <filename unknown>:0 
   at TestSessionManager.test () [0x00006] in /Users/bramsteenwinckel/Documents/client/New-Horizon/Assets/Editor/Tests/Session/TestSessionManager.cs:46 
   at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 

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
2
Best Answer

Answer by Tomek-Paszek · Mar 29, 2016 at 02:25 PM

Try using Editor Tests Runner to run the tests (Windows/Editor Tests Runner)

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 bsteenwi · Mar 29, 2016 at 11:48 PM 1
Share

Thanks, this solved it indeed! The standard unit tester in monodeveloper isn't able to unit test with unityengine components in my code. The Edit Tests Runner doesn't have any problems with this.

Thanks for helping me!

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

57 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

Related Questions

OSX: Assertion failed: Shader Compiler Socket Exception: Terminating shader compiler process, 0 retries left 0 Answers

Unity Editor 2018.4.20f1 - Editor Window on Macintosh is translucent and empty 0 Answers

Textmesg Pro not working in MacOSX for language with Special Characters 0 Answers

No editor test result file is created 0 Answers

Unity 5.2 on Mac OS: Oculus Rift screen just blank white 3 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