예제 #1
0
        private static void SetCount(BrowserTestResultItem item, string value)
        {
            int total, failures;

            ParseCount(value, out total, out failures);
            item.Total    = total;
            item.Failures = failures;
            item.Success  = failures == 0;
        }
예제 #2
0
        ///<summary>
        ///</summary>
        ///<param name="log"></param>
        ///<exception cref="NotImplementedException"></exception>
        public override void Parse(string log)
        {
            // parse it line by line
            var lines = log.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            Log.AddRange(lines);
            BrowserTestResultItem currentItem = this;
            BrowserTestResultItem lastItem    = null;
            int index = 0;

            while (index < lines.Length - 1)
            {
                var line = lines[index];
                if (line.StartsWith("Module Started:") || line.StartsWith("  Test Started:"))
                {
                    lastItem    = currentItem;
                    currentItem = new BrowserTestResultItem
                    {
                        Name = line.Substring("Module Started:".Length + 1)
                    };
                    if (lastItem == null)
                    {
                        throw new Exception("lst item is null?");
                    }
                    lastItem.Items.Add(currentItem.Name, currentItem);
                }
                else if (line.StartsWith("Module Done:") || line.StartsWith("  Test Done:"))
                {
                    SetCount(currentItem, line);
                    currentItem = lastItem;
                }
                else
                {
                    if (currentItem == null)
                    {
                        throw new Exception("log parse exception");
                    }
                    currentItem.Log.Add(line);
                }

                index++;
            }
            SetCount(this, lines[lines.Length - 1]);
        }