Skip to content
Snippets Groups Projects
Commit f46d4ee8 authored by Баглий Антон Павлович's avatar Баглий Антон Павлович
Browse files

ADD: NUnit XML report analyzer #55

parent 0f5e8438
Branches
No related merge requests found
......@@ -42,6 +42,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestVisitors", "TestVisitor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCodeGenerator", "TestCodeGenerator\TestCodeGenerator.csproj", "{186EE1C7-7F34-4428-8A82-F63C8D4368E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NunitReport", "NunitReportParser\NunitReport.csproj", "{88E96425-F1E4-4092-8524-9C13225D2214}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -120,6 +122,10 @@ Global
{186EE1C7-7F34-4428-8A82-F63C8D4368E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{186EE1C7-7F34-4428-8A82-F63C8D4368E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{186EE1C7-7F34-4428-8A82-F63C8D4368E8}.Release|Any CPU.Build.0 = Release|Any CPU
{88E96425-F1E4-4092-8524-9C13225D2214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88E96425-F1E4-4092-8524-9C13225D2214}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88E96425-F1E4-4092-8524-9C13225D2214}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88E96425-F1E4-4092-8524-9C13225D2214}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{88E96425-F1E4-4092-8524-9C13225D2214}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>BAgl</RootNamespace>
<AssemblyName>BAgl</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.12.0.3-beta1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace NunitReport
{
class ReportParser
{
private static List<XmlNode> cases = new List<XmlNode>();
static void ParseTestSuite(XmlNode node)
{
foreach (XmlNode child in node.ChildNodes)
{
if (child.Name == "test-suite")
{
ParseTestSuite(child);
}
else if (child.Name == "test-case")
{
cases.Add(child);
}
}
}
static void CountGrades()
{
string configPath = @"../../../grades/Grades.json";
JObject grades = JObject.Parse(File.ReadAllText(configPath));
JArray tasks = (JArray) grades["Tasks"];
var countedGrades = new Dictionary<string, int>();
foreach (XmlNode testcase in cases)
{
string caseClass = testcase.Attributes["classname"].Value.Split('.')[0];
string caseName = testcase.Attributes["name"].Value;
foreach (JObject task in tasks)
{
if ((string) task["name"] == caseClass)
{
int maxGrade = (int) task["grades"][caseName];
if (testcase.Attributes["result"].Value == "Passed")
{
if (!countedGrades.ContainsKey(caseClass))
{
countedGrades[caseClass] = 0;
}
countedGrades[caseClass] += maxGrade;
}
}
}
//System.Console.Out.WriteLine(countedGrades[caseClass]);
}
foreach (KeyValuePair<string, int> g in countedGrades)
{
if (g.Value > 0)
{
System.Console.Out.WriteLine(g.Key + " = " + g.Value.ToString());
}
}
}
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"../../../TestResult.xml");
// XmlNodeList nodes = doc.DocumentElement.SelectNodes("test-run/test-suite");
XmlNodeList nodes = doc.DocumentElement.ChildNodes;
foreach (XmlNode node in nodes)
{
Console.Out.WriteLine(node.Name);
if (node.Name == "test-suite")
{
ParseTestSuite(node);
}
}
CountGrades();
System.Console.WriteLine("number of running tests: " + cases.Count);
}
}
class ReportNode
{
public string id;
public string title;
public string author;
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("BAgl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BAgl")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("88e96425-f1e4-4092-8524-9c13225d2214")]
// Сведения о версии сборки состоят из следующих четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3-beta1" targetFramework="net461" />
</packages>
\ No newline at end of file
{
"Tasks": [
{ "name": "TestSimpleLexer",
"grades": {
"TestId": 1,
"TestOps": 1,
"TestKeywords": 1,
"TestOpsFail": 1,
"TestAssigns": 1,
"TestComparisons": 1,
"TestComparisonsAndOps": 1,
"TestComment": 1,
"TestCommentFileEnd": 1,
"TestCommentNextLine": 1,
"TestMultLineComment": 1,
"TestCommentFileEnd": 1,
"TestCommentNextLine": 1,
"TestCommentNotClosed": 1
}
},
{ "name": "TestLexer",
"grades": {
"TestIntParse": 1,
"TestIntFailDot": 1,
"TestIntFailSymbol": 1,
"TestIntFailEpty": 1,
"TestIntCollectNumber": 1,
"TestIdParse": 1,
"TestIdEmpty": 1,
"TestIdCaps": 1,
"TestIdNumbers": 1,
"TestIdUnderscore" : 1,
"TestIdDot": 1,
"TestIdDollar": 1,
"TestIntNotZeroParse": 1,
"TestIntNotZeroFail": 1,
"TestIntNotZeroPass": 1,
"TestLetterDigitParse": 1,
"TestLetterDigitFail": 1,
"TestLetterListParse": 1,
"TestLetterListFail": 1,
"TestDigitListParse": 1,
"TestDigitListFail": 1,
"TestLetterDigitGroupParse": 1,
"TestLetterDigitGroupFail": 1,
"TestDoubleParse": 1,
"TestDoubleFail": 1,
"TestQuotedStringParse": 1,
"TestQuotedStringFail": 1,
"TestCommentParse": 1,
"TestCommentFail": 1,
"TestIdChainParse": 1,
"TestIdChainFail": 1
}
}
]
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment