[TUnit][Add any logs into Framework] 03/184503/2
authornguyen.vtan <nguyen.vtan@samsung.com>
Wed, 18 Jul 2018 09:25:56 +0000 (16:25 +0700)
committernguyen.vtan <nguyen.vtan@samsung.com>
Wed, 18 Jul 2018 09:30:13 +0000 (16:30 +0700)
Change-Id: I9499a2d3b198283e4fb034c8dcf0f502cc13322d

tct-suite-vs/nunit.framework/Internal/Commands/OneTimeSetUpCommand.cs
tct-suite-vs/nunit.framework/Internal/Commands/OneTimeTearDownCommand.cs
tct-suite-vs/nunit.framework/Internal/Execution/CompositeWorkItem.cs
tct-suite-vs/nunit.framework/TUnit/TAsyncThreadMgr.cs
tct-suite-vs/nunit.framework/TUnit/TSettings.cs
tct-suite-vs/nunit.framework/TUnit/TTestMethodCommand.cs

index f007f0b..35a1632 100755 (executable)
@@ -20,7 +20,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 // ***********************************************************************\r
-#define PORTABLE
+#define PORTABLE\r
 #define TIZEN\r
 #define NUNIT_FRAMEWORK\r
 #define NUNITLITE\r
@@ -51,7 +51,7 @@ namespace NUnit.Framework.Internal.Commands
         /// <param name="setUpTearDown">A SetUpTearDownList for use by the command</param>\r
         /// <param name="actions">A List of TestActionItems to be run after Setup</param>\r
         public OneTimeSetUpCommand(TestSuite suite, List<SetUpTearDownItem> setUpTearDown, List<TestActionItem> actions)\r
-            : base(suite) \r
+            : base(suite)\r
         {\r
             _suite = suite;\r
             _typeInfo = suite.TypeInfo;\r
index 6a05cd6..342a345 100755 (executable)
@@ -20,7 +20,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 // ***********************************************************************\r
-#define PORTABLE
+#define PORTABLE\r
 #define TIZEN\r
 #define NUNIT_FRAMEWORK\r
 #define NUNITLITE\r
index 84d3391..5401051 100755 (executable)
@@ -218,6 +218,7 @@ namespace NUnit.Framework.Internal.Execution
         {\r
             try\r
             {\r
+                TLogger.Write("##### Execute OneTimeSetUp #####");\r
                 _setupCommand.Execute(Context);\r
 \r
                 // SetUp may have changed some things in the environment\r
@@ -382,7 +383,7 @@ namespace NUnit.Framework.Internal.Execution
             // this test started, so we have to re-establish\r
             // the proper execution environment\r
             this.Context.EstablishExecutionEnvironment();\r
-\r
+            TLogger.Write("##### Execute OnTimeTearDown #####");\r
             _teardownCommand.Execute(this.Context);\r
         }\r
 \r
index 945470f..0b8ecfa 100755 (executable)
@@ -93,6 +93,7 @@ namespace NUnit.Framework.TUnit
             {
                 return;
             }
+            TLogger.Write("##### RunTestMethod in TAsyncThreadMgr class #####");
             if (IsAsyncOperation)
                 RunAsyncTestMethod();
             else
@@ -101,6 +102,7 @@ namespace NUnit.Framework.TUnit
 
         public void RunAsyncTestMethod()
         {
+            TLogger.Write("##### RunAsyncTestMethod in TAsyncThreadMgr class #####");
             try
             {
                 result = null;
@@ -144,6 +146,7 @@ namespace NUnit.Framework.TUnit
 
         public void RunNonAsyncTestMethod()
         {
+            TLogger.Write("##### RunNonAsyncTestMethod in TAsyncThreadMgr class #####");
             try
             {
                 runSetup();
@@ -175,6 +178,7 @@ namespace NUnit.Framework.TUnit
         #region add by nguyen.vtan rewrite setup & teardown method to run on main thread
         public void runSetup()
         {
+            TLogger.Write("##### runSetup in TAsyncThreadMgr class #####");
             foreach (var item in _setupteardownItem)
             {
                 if (item?._setUpMethods != null)
@@ -186,6 +190,7 @@ namespace NUnit.Framework.TUnit
         }
         public void runTearDown()
         {
+            TLogger.Write("##### runTearDown in TAsyncThreadMgr class #####");
             if (context?.ExecutionStatus == TestExecutionStatus.AbortRequested)
             {
                 return;
index 1f91614..b7c9b28 100755 (executable)
@@ -43,9 +43,10 @@ namespace NUnit.Framework.TUnit
             return _instance;
         }
 
-               private TSettings() {
-                       IsManual = false;
-               }
+        private TSettings()
+        {
+            IsManual = false;
+        }
 
         public void SetDefaultTCDelay(int defaultTCDelay)
         {
@@ -70,15 +71,16 @@ namespace NUnit.Framework.TUnit
         #region testkit-stub api
         // [Hyukin.Kwon-code]: session_id for communication with testkit-stub
         private static bool _isSlaveMode = false;
-        private static int _session_id ;
+        private static int _session_id;
         private static string _server = "http://127.0.0.1:8000";
-       // private static string _proxy = "http://10.112.1.184:8080/";
+        // private static string _proxy = "http://10.112.1.184:8080/";
 
         public static bool IsLastTC = false;
         private static string _testcase_id;
 
         public void ConnectTestkitStub()
         {
+            TLogger.Write("############### ConnectTestkitStub ###############");
             Random rnd = new Random();
             _session_id = rnd.Next(1000, 9999);
             _server = "http://127.0.0.1:8000";
@@ -88,6 +90,7 @@ namespace NUnit.Framework.TUnit
 
         private bool SyncSessionIdRequest()
         {
+            TLogger.Write("############### In SyncSessionIdRequest ###############");
             Console.WriteLine("[TUnitTest] - " + "In SyncSessionIdRequest");
 
             string result = RequestGET("init_session_id", _session_id);
@@ -111,6 +114,7 @@ namespace NUnit.Framework.TUnit
 
         private bool CheckServer()
         {
+            TLogger.Write("############### In CheckServer ###############");
             Console.WriteLine("[TUnitTest] - " + "In CheckServer");
             string result = RequestGET("check_server");
 
@@ -126,12 +130,14 @@ namespace NUnit.Framework.TUnit
 
         private string RequestGET(string key)
         {
+            TLogger.Write("############### In RequestGET ###############");
             Console.WriteLine("[TUnitTest] - " + "In RequestGET");
 
             string result = null;
             string url = _server + "/" + key;
 
             Console.WriteLine("[TUnitTest] - " + "RequestGET url : " + url);
+            TLogger.Write("############### RequestGET url ###############");
 
             try
             {
@@ -162,6 +168,7 @@ namespace NUnit.Framework.TUnit
                 StreamReader reader = new StreamReader(stream);
                 result = reader.ReadToEnd();
                 Console.WriteLine("[TUnitTest] - " + "RequestGET Result : " + result);
+                TLogger.Write("############### RequestGET Result : " + result + " ###############");
                 stream.Dispose();
                 response.Dispose();
             }
@@ -175,12 +182,14 @@ namespace NUnit.Framework.TUnit
 
         private string RequestGET(string key, int sessionId)
         {
+            TLogger.Write("############### In RequestGET ###############");
             Console.WriteLine("[TUnitTest] - " + "In RequestGET");
 
             string result = null;
             string url = _server + "/" + key + "?session_id=" + _session_id;
 
             Console.WriteLine("[TUnitTest] - " + "RequestGET url : " + url);
+            TLogger.Write("############### RequestGET url : " + url + " ###############");
 
             try
             {
@@ -293,6 +302,7 @@ namespace NUnit.Framework.TUnit
             Console.WriteLine("[TUnitTest] - " + "In AskNextStepRequest");
 
             string result = RequestGET("ask_next_step", _session_id);
+            TLogger.Write("############### In AskNextStepRequest ###############");
 
             if (result == null)
                 return false;
@@ -313,6 +323,10 @@ namespace NUnit.Framework.TUnit
             Console.WriteLine("[TUnitTest] - " + "In AutoTestTaskRequest");
 
             string result = RequestGET("auto_test_task", _session_id);
+            TLogger.Write("############### In AutoTestTaskRequest ###############");
+            TLogger.Write("");
+            TLogger.Write("");
+            TLogger.Write("");
 
             if (result == null)
                 return "";
@@ -342,6 +356,7 @@ namespace NUnit.Framework.TUnit
         {
             Console.WriteLine("[TUnitTest] - " + "In RequestPOST");
             string result = null;
+            TLogger.Write("############### In RequestPOST ###############");
             string url = _server + "/" + key;
             json = json + "&session_id=" + _session_id;
 
@@ -363,7 +378,7 @@ namespace NUnit.Framework.TUnit
 
                 if (proxy != null)
                 {
-                    Console.WriteLine("[TUnitTest] - Proxy is NOT null. Is ByPassed : "+proxy.IsBypassed(new Uri(url)));
+                    Console.WriteLine("[TUnitTest] - Proxy is NOT null. Is ByPassed : " + proxy.IsBypassed(new Uri(url)));
                 }
                 else
                 {
@@ -402,48 +417,51 @@ namespace NUnit.Framework.TUnit
             return result;
         }
 
-               public void SubmitManualResult()
-               {
-                       LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Manual test execution done.");
-
-                       if (_isSlaveMode == true)
-                       {
-                               LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Submit result to inform manual execution done.");
-                               RequestGET("generate_xml");
-                       }
-               }
-
-               #if TIZEN
-               public void NextStepRequest()
-               {
-                       if (AskNextStepRequest())
-                       {
-                           CheckExecutionProgressRequest();
-                       }
-                       if (AskNextStepRequest())
-                       {
-                           Testcase_ID = AutoTestTaskRequest();
-                       }
-               }
-
-               public SingleTestDoneEventArgs GetSingleTestDoneEventArgs() {
-                       SingleTestDoneEventArgs singleTestArgs = new SingleTestDoneEventArgs();
-                       singleTestArgs.Name = Testcase_ID;
-                       singleTestArgs.Result = TCResult;
-                       singleTestArgs.Message = TCMessage;
+        public void SubmitManualResult()
+        {
+            TLogger.Write("############### SubmitManualResult ###############");
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Manual test execution done.");
+
+            if (_isSlaveMode == true)
+            {
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Submit result to inform manual execution done.");
+                RequestGET("generate_xml");
+            }
+        }
+
+#if TIZEN
+        public void NextStepRequest()
+        {
+            TLogger.Write("############### NextStepRequest ###############");
+            if (AskNextStepRequest())
+            {
+                CheckExecutionProgressRequest();
+            }
+            if (AskNextStepRequest())
+            {
+                Testcase_ID = AutoTestTaskRequest();
+            }
+        }
+
+        public SingleTestDoneEventArgs GetSingleTestDoneEventArgs()
+        {
+            SingleTestDoneEventArgs singleTestArgs = new SingleTestDoneEventArgs();
+            singleTestArgs.Name = Testcase_ID;
+            singleTestArgs.Result = TCResult;
+            singleTestArgs.Message = TCMessage;
             return singleTestArgs;
-               }
+        }
 
         public bool IsSlaveMode
         {
             get { return _isSlaveMode; }
         }
 
-               public bool IsManual
-               {
-                       get;
-                       set;
-               }
+        public bool IsManual
+        {
+            get;
+            set;
+        }
 
         public string Testcase_ID
         {
@@ -452,26 +470,28 @@ namespace NUnit.Framework.TUnit
         }
 
 
-               public string TCResult {
-                       get;
-                       set;
-               }
+        public string TCResult
+        {
+            get;
+            set;
+        }
 
-               public string TCMessage {
-                       get;
-                       set;
-               }
+        public string TCMessage
+        {
+            get;
+            set;
+        }
 
-               #endif
+#endif
 
         #endregion
     }
 
 
-       public class SingleTestDoneEventArgs : EventArgs
-       {
-               public string Name { get; set; }
-               public string Result { get; set; }
-               public string Message { get; set; }
-       }
+    public class SingleTestDoneEventArgs : EventArgs
+    {
+        public string Name { get; set; }
+        public string Result { get; set; }
+        public string Message { get; set; }
+    }
 }
index 10c748b..6db1586 100755 (executable)
@@ -87,6 +87,7 @@ namespace NUnit.Framework.TUnit
 #if NET_4_0 || NET_4_5 || PORTABLE || TIZEN
         private object RunAsyncTestMethod(TestExecutionContext context)
         {
+            TLogger.Write("##### RunAsyncTestMethod in TTestMethodCommand class #####");
             #region tronghieu.d - invoke async test method in application thread. This thread is blocked for waiting result.
             using (AsyncInvocationRegion region = AsyncInvocationRegion.Create(testMethod.Method.MethodInfo))
             {
@@ -115,6 +116,7 @@ namespace NUnit.Framework.TUnit
 
         private object RunNonAsyncTestMethod(TestExecutionContext context)
         {
+            TLogger.Write("##### RunNonAsyncTestMethod in TTestMethodCommand class #####");
             #region tronghieu.d - invoke async test method in application thread. This thread is blocked for waiting result.
             TAsyncThreadMgr asyncThreadMgr = TAsyncThreadMgr.GetInstance();
             asyncThreadMgr.SetData(this, testMethod, arguments, context, false);