Skip to content

Commit

Permalink
Improved test logging, first steps for XUnit / NUnit compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven De Kock committed Jul 23, 2011
1 parent 51577a4 commit 2dd6932
Show file tree
Hide file tree
Showing 23 changed files with 659 additions and 181 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*.user
_ReSharper.*/
output/*
resharper.log
TestResults/
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<AssemblyName>AgUnit.Runner.Resharper60.TaskRunner</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ReferencePath>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\JetBrains\ReSharper\v6.0\vs10.0@InstallDir)</ReferencePath>
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/ReSharper.Plugin AgUnit.Runner.Resharper60.dll /ReSharper.LogFile C:\resharper.log /ReSharper.LogLevel Verbose ..\src\DummyTests\VS2010\DummyTests.sln</StartArguments>
<TargetFrameworkProfile />
<ReferencePath>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\JetBrains\ReSharper\v6.0\vs10.0@InstallDir)</ReferencePath>
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/ReSharper.Plugin AgUnit.Runner.Resharper60.dll /ReSharper.LogFile C:\resharper.log /ReSharper.LogLevel Verbose ..\src\DummyTests\VS2010\DummyTests.sln</StartArguments>
<OutputPath>..\..\output\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -54,9 +54,23 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTestProvider\MSTest\MsTestAssemblyTaskProvider.cs" />
<Compile Include="UnitTestRunner\Silverlight\DebugLogger.cs" />
<Compile Include="UnitTestRunner\Silverlight\Execution\AssemblyTask.cs" />
<Compile Include="UnitTestRunner\Silverlight\Execution\ClassTask.cs" />
<Compile Include="UnitTestRunner\Silverlight\Execution\MethodTask.cs" />
<Compile Include="UnitTestProvider\MSTest\MsTestClassTaskProvider.cs" />
<Compile Include="UnitTestProvider\MSTest\MsTestMethodTaskProvider.cs" />
<Compile Include="UnitTestRunner\Silverlight\Providers\IAssemblyTaskProvider.cs" />
<Compile Include="UnitTestRunner\Silverlight\Providers\IClassTaskProvider.cs" />
<Compile Include="UnitTestRunner\Silverlight\Providers\IMethodTaskProvider.cs" />
<Compile Include="UnitTestRunner\Silverlight\SilverlightResultsHandler.cs" />
<Compile Include="UnitTestRunner\Silverlight\SilverlightUnitTestTaskRunner.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UnitTestRunner\Silverlight\Execution\TaskEnvironment.cs" />
<Compile Include="UnitTestRunner\Silverlight\Execution\TaskNode.cs" />
<Compile Include="UnitTestRunner\Silverlight\Providers\TaskNodeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\sl\StatLight\src\StatLight.Core\StatLight.Core.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;
using JetBrains.ReSharper.TaskRunnerFramework;
using JetBrains.ReSharper.UnitTestRunner.MSTest;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestProvider.MSTest
{
public class MsTestAssemblyTaskProvider : IAssemblyTaskProvider
{
public bool IsAssemblyTask(RemoteTask task)
{
return task is MsTestTestAssemblyTask;
}

private MsTestTestAssemblyTask GetTask(RemoteTask task)
{
return (MsTestTestAssemblyTask)task;
}

public string GetXapPath(RemoteTask task)
{
var assemblyTask = GetTask(task);

return assemblyTask.AssemblyLocation.Replace(".dll", ".xap"); // TODO: Find a way to get this from the project settings.
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;
using JetBrains.ReSharper.TaskRunnerFramework;
using JetBrains.ReSharper.UnitTestRunner.MSTest;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestProvider.MSTest
{
public class MsTestClassTaskProvider : IClassTaskProvider
{
public bool IsClassTask(RemoteTask task)
{
return task is MsTestTestClassTask;
}

private MsTestTestClassTask GetTask(RemoteTask task)
{
return (MsTestTestClassTask)task;
}

public string GetFullClassName(RemoteTask task)
{
var classTask = GetTask(task);

return classTask.TypeName;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;
using JetBrains.ReSharper.TaskRunnerFramework;
using JetBrains.ReSharper.UnitTestRunner.MSTest;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestProvider.MSTest
{
public class MsTestMethodTaskProvider : IMethodTaskProvider
{
public bool IsMethodTask(RemoteTask task)
{
return task is MsTestTestMethodTask;
}

private MsTestTestMethodTask GetTask(RemoteTask task)
{
return (MsTestTestMethodTask)task;
}

public string GetFullMethodName(RemoteTask task)
{
var methodTask = GetTask(task);

return string.Format("{0}.{1}", methodTask.TypeName, methodTask.ShortName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using StatLight.Core.Common;
using StatLight.Core.Properties;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight
{
// TODO: Move this to StatLight
public class DebugLogger : LoggerBase
{
private readonly Settings settings;

public DebugLogger()
: this(LogChatterLevels.Error | LogChatterLevels.Warning | LogChatterLevels.Information, Settings.Default)
{ }

public DebugLogger(LogChatterLevels logChatterLevel)
: this(logChatterLevel, Settings.Default)
{ }

public DebugLogger(LogChatterLevels logChatterLevel, Settings settings)
: base(logChatterLevel)
{
this.settings = settings;
}

public override void Information(string message)
{
if (ShouldLog(LogChatterLevels.Information))
Write(message, "Information", false);
}

public override void Debug(string message)
{
if (ShouldLog(LogChatterLevels.Debug))
Write(message, "Debug", true);
}

public override void Debug(string message, bool writeNewLine)
{
if (ShouldLog(LogChatterLevels.Debug))
Write(message, "Debug", writeNewLine);
}

public override void Warning(string message)
{
if (ShouldLog(LogChatterLevels.Warning))
Write(message, "Warning", false);
}

public override void Error(string message)
{
if (ShouldLog(LogChatterLevels.Error))
Write(message, "Error", true);
}

private void Write(string message, string type, bool useNewLine)
{
message = string.Format("[{0}]: {1}", type, message);

if (useNewLine)
{
System.Diagnostics.Debug.WriteLine(message);
}
else
{
System.Diagnostics.Debug.Write(message);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Execution
{
public class AssemblyTask
{
public TaskNode Node { get; private set; }
public IAssemblyTaskProvider AssemblyTaskProvider { get; private set; }

public AssemblyTask(TaskNode node, IAssemblyTaskProvider assemblyTaskProvider)
{
Node = node;
AssemblyTaskProvider = assemblyTaskProvider;
}

public void Execute(Action<AssemblyTask> execute)
{
Node.Execute(execute, this);
}

public string GetXapPath()
{
return AssemblyTaskProvider.GetXapPath(Node.Task);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Execution
{
public class ClassTask
{
public TaskNode Node { get; private set; }
public IClassTaskProvider ClassTaskProvider { get; private set; }

public ClassTask(TaskNode node, IClassTaskProvider classTaskProvider)
{
Node = node;
ClassTaskProvider = classTaskProvider;
}

public string GetFullClassName()
{
return ClassTaskProvider.GetFullClassName(Node.Task);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Execution
{
public class MethodTask
{
public TaskNode Node { get; private set; }
public IMethodTaskProvider MethodTaskProvider { get; private set; }

public MethodTask(TaskNode node, IMethodTaskProvider methodTaskProvider)
{
Node = node;
MethodTaskProvider = methodTaskProvider;
}

public string GetFullMethodName()
{
return MethodTaskProvider.GetFullMethodName(Node.Task);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Providers;
using JetBrains.ReSharper.TaskRunnerFramework;

namespace AgUnit.Runner.Resharper60.TaskRunner.UnitTestRunner.Silverlight.Execution
{
public class TaskEnvironment
{
public IRemoteTaskServer Server { get; private set; }
public IEnumerable<IAssemblyTaskProvider> AssemblyTaskProviders { get; private set; }
public IEnumerable<IClassTaskProvider> ClassTaskProviders { get; private set; }
public IEnumerable<IMethodTaskProvider> MethodTaskProviders { get; private set; }

public TaskEnvironment(IRemoteTaskServer server,
IEnumerable<IAssemblyTaskProvider> assemblyTaskProviders,
IEnumerable<IClassTaskProvider> classTaskProviders,
IEnumerable<IMethodTaskProvider> methodTaskProviders)
{
Server = server;
AssemblyTaskProviders = assemblyTaskProviders;
ClassTaskProviders = classTaskProviders;
MethodTaskProviders = methodTaskProviders;
}
}
}
Loading

0 comments on commit 2dd6932

Please sign in to comment.