Quantcast
Channel: Questions in topic: "unit"
Viewing all articles
Browse latest Browse all 68

Test a Debug Log with a combined log message

$
0
0
I'm working on my Unit tests and using the Unity Testing Framework. In several functions I try and catch a few lines and when the catch phrase is called I through a Debug.Log-message, witch is a combination of a static string and e.g. a System.Exception. ---------- **How to test the combined log messages?** ---------- I tried the following: public static void LoadStartParameterTest_ReturnLogs(string input, LogType logType, string log) { IniLoader.LoadStartParameter(input); LogAssert.Expect(logType, log); } But the test failed, because I just know the content of the static string and the parameter "log" is a combined one as discussed. ---------- So I tried: public static void LoadStartParameterTest_ReturnException(string input, string log) { var ex = Assert.Catch(()=>IniLoader.LoadStartParameter(input)); StringAssert.Contains(log, ex.Message); } But the test failed again, because it is a Debug.Log and not a System.Exception. ---------- So I would like to combine the Assert.Catch with the UnityEngine.LogType or get something like LogAssert.Contains. Has anyone any experience in that field?

Viewing all articles
Browse latest Browse all 68

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>