Skip to content

Commit

Permalink
Merge pull request #56 from JSkimming/testing-improvements
Browse files Browse the repository at this point in the history
Testing improvments
  • Loading branch information
JSkimming authored Apr 5, 2019
2 parents 898e831 + bfe14ff commit 6537e8f
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 90 deletions.
52 changes: 51 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
FROM microsoft/aspnetcore-build:2.0.0
########################################################################################################################
# .NET Core 1.1
FROM mcr.microsoft.com/dotnet/core/sdk:1.1

ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

WORKDIR /work

# Copy just the solution and proj files to make best use of docker image caching
COPY ./castle.core.asyncinterceptor.sln .
COPY ./src/Castle.Core.AsyncInterceptor/Castle.Core.AsyncInterceptor.csproj ./src/Castle.Core.AsyncInterceptor/Castle.Core.AsyncInterceptor.csproj
COPY ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

# Run restore on just the project files, this should cache the image after restore.
RUN dotnet restore

COPY . .

# Build to ensure the tests are their own distinct step
RUN dotnet build -f netcoreapp1.1 -c Debug ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

# Run unit tests
RUN dotnet test --no-build -c Debug -f netcoreapp1.1 test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

########################################################################################################################
# .NET Core 2.1
FROM mcr.microsoft.com/dotnet/core/sdk:2.1

ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

WORKDIR /work

# Copy just the solution and proj files to make best use of docker image caching
COPY ./castle.core.asyncinterceptor.sln .
COPY ./src/Castle.Core.AsyncInterceptor/Castle.Core.AsyncInterceptor.csproj ./src/Castle.Core.AsyncInterceptor/Castle.Core.AsyncInterceptor.csproj
COPY ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

# Run restore on just the project files, this should cache the image after restore.
RUN dotnet restore

COPY . .

# Build to ensure the tests are their own distinct step
RUN dotnet build --no-restore -f netcoreapp2.0 -c Debug ./test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

# Run unit tests
RUN dotnet test --no-restore --no-build -c Debug -f netcoreapp2.0 test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj

########################################################################################################################
# .NET Core 2.2
FROM mcr.microsoft.com/dotnet/core/sdk:2.2

ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true

Expand Down
21 changes: 13 additions & 8 deletions coverage.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@
)
::@echo %report_exe%

@FOR /r %%F IN (*xunit.console.exe) DO @SET xunit_exe=%%F
@IF NOT EXIST "%xunit_exe%" (
echo Unable to find xUnit console runner.
EXIT /B 2
)
::@echo %xunit_exe%

@SET results_path=%~dp0test\TestResults
@SET test_assemblies=%~dp0test\Castle.Core.AsyncInterceptor.Tests\bin\%config%\net47\Castle.Core.AsyncInterceptor.Tests.dll
::@SET test_assemblies=%test_assemblies% %~dp0test\More.Tests\bin\%config%\net47\More.Tests.dll
@SET xunit_results=%results_path%\Xunit.Tests.html
@SET coverage_filter=+[Castle.Core.AsyncInterceptor*]* -[*.Tests]*
@SET coverage_results=%results_path%\Test.Coverage.xml
Expand All @@ -51,19 +60,15 @@
EXIT /B 2
)

cd "%~dp0test\Castle.Core.AsyncInterceptor.Tests"
::@echo "%xunit_exe%" %test_assemblies% -noshadow -html "%xunit_results%"
::@"%xunit_exe%" %test_assemblies% -noshadow -html "%xunit_results%"

::@echo dotnet.exe xunit -framework net47 -configuration %config% -nobuild -noshadow -html %xunit_results%
::@dotnet.exe xunit -framework net47 -configuration %config% -nobuild -noshadow -html %xunit_results%

@echo "%cover_exe%" -register:user "-target:dotnet.exe" "-targetargs:xunit -framework net47 -configuration %config% -nobuild -noshadow -html %xunit_results%" -returntargetcode -filter:^"%coverage_filter%^" "-output:%coverage_results%"
@"%cover_exe%" -register:user "-target:dotnet.exe" "-targetargs:xunit -framework net47 -configuration %config% -nobuild -noshadow -html %xunit_results%" -returntargetcode -filter:^"%coverage_filter%^" "-output:%coverage_results%"
@echo "%cover_exe%" -register:user "-target:%xunit_exe%" "-targetargs:%test_assemblies% -noshadow -html %xunit_results%" -returntargetcode -filter:^"%coverage_filter%^" "-output:%coverage_results%"
@"%cover_exe%" -register:user "-target:%xunit_exe%" "-targetargs:%test_assemblies% -noshadow -html %xunit_results%" -returntargetcode -filter:^"%coverage_filter%^" "-output:%coverage_results%"
@IF ERRORLEVEL 1 (
echo Error executing the xunit tests
EXIT /B 2
)

cd "%~dp0"

@echo "%report_exe%" -verbosity:Error "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
@"%report_exe%" -verbosity:Error "-reports:%coverage_results%" "-targetdir:%results_path%\Report" -reporttypes:Html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ namespace Castle.DynamicProxy
using System.Threading.Tasks;
using Castle.DynamicProxy.InterfaceProxies;
using Xunit;
using Xunit.Abstractions;

public abstract class WhenExceptionInterceptingSynchronousVoidMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.SynchronousVoidExceptionMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenExceptionInterceptingSynchronousVoidMethodsBase(int msDelay)
protected WhenExceptionInterceptingSynchronousVoidMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -62,27 +65,31 @@ public void ShouldAllowExceptionHandling()
public class WhenExceptionInterceptingSynchronousVoidMethodsWithNoDelay
: WhenExceptionInterceptingSynchronousVoidMethodsBase
{
public WhenExceptionInterceptingSynchronousVoidMethodsWithNoDelay() : base(0)
public WhenExceptionInterceptingSynchronousVoidMethodsWithNoDelay(ITestOutputHelper output)
: base(output, 0)
{
}
}

public class WhenExceptionInterceptingSynchronousVoidMethodsWithADelay
: WhenExceptionInterceptingSynchronousVoidMethodsBase
{
public WhenExceptionInterceptingSynchronousVoidMethodsWithADelay() : base(10)
public WhenExceptionInterceptingSynchronousVoidMethodsWithADelay(ITestOutputHelper output)
: base(output, 10)
{
}
}

public abstract class WhenExceptionInterceptingSynchronousResultMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.SynchronousResultExceptionMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenExceptionInterceptingSynchronousResultMethodsBase(int msDelay)
protected WhenExceptionInterceptingSynchronousResultMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -127,27 +134,29 @@ public void ShouldAllowExceptionHandling()
public class WhenExceptionInterceptingSynchronousResultMethodsWithNoDelay
: WhenExceptionInterceptingSynchronousResultMethodsBase
{
public WhenExceptionInterceptingSynchronousResultMethodsWithNoDelay() : base(0)
public WhenExceptionInterceptingSynchronousResultMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenExceptionInterceptingSynchronousResultMethodsWithADelay
: WhenExceptionInterceptingSynchronousResultMethodsBase
{
public WhenExceptionInterceptingSynchronousResultMethodsWithADelay() : base(10)
public WhenExceptionInterceptingSynchronousResultMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}

public abstract class WhenExceptionInterceptingAsynchronousVoidMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.AsynchronousVoidExceptionMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenExceptionInterceptingAsynchronousVoidMethodsBase(int msDelay)
protected WhenExceptionInterceptingAsynchronousVoidMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -195,27 +204,29 @@ await Assert.ThrowsAsync<InvalidOperationException>(_proxy.AsynchronousVoidExcep
public class WhenExceptionInterceptingAsynchronousVoidMethodsWithNoDelay
: WhenExceptionInterceptingAsynchronousVoidMethodsBase
{
public WhenExceptionInterceptingAsynchronousVoidMethodsWithNoDelay() : base(0)
public WhenExceptionInterceptingAsynchronousVoidMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenExceptionInterceptingAsynchronousVoidMethodsWithADelay
: WhenExceptionInterceptingAsynchronousVoidMethodsBase
{
public WhenExceptionInterceptingAsynchronousVoidMethodsWithADelay() : base(10)
public WhenExceptionInterceptingAsynchronousVoidMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}

public abstract class WhenExceptionInterceptingAsynchronousResultMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.AsynchronousResultExceptionMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenExceptionInterceptingAsynchronousResultMethodsBase(int msDelay)
protected WhenExceptionInterceptingAsynchronousResultMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -263,15 +274,15 @@ await Assert.ThrowsAsync<InvalidOperationException>(_proxy.AsynchronousResultExc
public class WhenExceptionInterceptingAsynchronousResultMethodsWithNoDelay
: WhenExceptionInterceptingAsynchronousResultMethodsBase
{
public WhenExceptionInterceptingAsynchronousResultMethodsWithNoDelay() : base(0)
public WhenExceptionInterceptingAsynchronousResultMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenExceptionInterceptingAsynchronousResultMethodsWithADelay
: WhenExceptionInterceptingAsynchronousResultMethodsBase
{
public WhenExceptionInterceptingAsynchronousResultMethodsWithADelay() : base(10)
public WhenExceptionInterceptingAsynchronousResultMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ namespace Castle.DynamicProxy
using System.Threading.Tasks;
using Castle.DynamicProxy.InterfaceProxies;
using Xunit;
using Xunit.Abstractions;

public abstract class WhenInterceptingSynchronousVoidMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.SynchronousVoidMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenInterceptingSynchronousVoidMethodsBase(int msDelay)
protected WhenInterceptingSynchronousVoidMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work by the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -57,27 +60,29 @@ public void ShouldAllowProcessingAfterInvocation()
public class WhenInterceptingSynchronousVoidMethodsWithNoDelay
: WhenInterceptingSynchronousVoidMethodsBase
{
public WhenInterceptingSynchronousVoidMethodsWithNoDelay() : base(0)
public WhenInterceptingSynchronousVoidMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenInterceptingSynchronousVoidMethodsWithADelay
: WhenInterceptingSynchronousVoidMethodsBase
{
public WhenInterceptingSynchronousVoidMethodsWithADelay() : base(10)
public WhenInterceptingSynchronousVoidMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}

public abstract class WhenInterceptingSynchronousResultMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.SynchronousResultMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenInterceptingSynchronousResultMethodsBase(int msDelay)
protected WhenInterceptingSynchronousResultMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -117,27 +122,29 @@ public void ShouldAllowProcessingAfterInvocation()
public class WhenInterceptingSynchronousResultMethodsWithNoDelay
: WhenInterceptingSynchronousResultMethodsBase
{
public WhenInterceptingSynchronousResultMethodsWithNoDelay() : base(0)
public WhenInterceptingSynchronousResultMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenInterceptingSynchronousResultMethodsWithADelay
: WhenInterceptingSynchronousResultMethodsBase
{
public WhenInterceptingSynchronousResultMethodsWithADelay() : base(10)
public WhenInterceptingSynchronousResultMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}

public abstract class WhenInterceptingAsynchronousVoidMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.AsynchronousVoidMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenInterceptingAsynchronousVoidMethodsBase(int msDelay)
protected WhenInterceptingAsynchronousVoidMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -177,27 +184,29 @@ public async Task ShouldAllowProcessingAfterInvocation()
public class WhenInterceptingAsynchronousVoidMethodsWithNoDelay
: WhenInterceptingAsynchronousVoidMethodsBase
{
public WhenInterceptingAsynchronousVoidMethodsWithNoDelay() : base(0)
public WhenInterceptingAsynchronousVoidMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenInterceptingAsynchronousVoidMethodsWithADelay
: WhenInterceptingAsynchronousVoidMethodsBase
{
public WhenInterceptingAsynchronousVoidMethodsWithADelay() : base(10)
public WhenInterceptingAsynchronousVoidMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}

public abstract class WhenInterceptingAsynchronousResultMethodsBase
{
private const string MethodName = nameof(IInterfaceToProxy.AsynchronousResultMethod);
private readonly ListLogger _log = new ListLogger();
private readonly ListLogger _log;
private readonly IInterfaceToProxy _proxy;

protected WhenInterceptingAsynchronousResultMethodsBase(int msDelay)
protected WhenInterceptingAsynchronousResultMethodsBase(ITestOutputHelper output, int msDelay)
{
_log = new ListLogger(output);

// The delay is used to simulate work my the interceptor, thereof not always continuing on the same thread.
var interceptor = new TestAsyncInterceptorBase(_log, msDelay);
_proxy = ProxyGen.CreateProxy(_log, interceptor);
Expand Down Expand Up @@ -238,15 +247,15 @@ public async Task ShouldAllowProcessingAfterInvocation()
public class WhenInterceptingAsynchronousResultMethodsWithNoDelay
: WhenInterceptingAsynchronousResultMethodsBase
{
public WhenInterceptingAsynchronousResultMethodsWithNoDelay() : base(0)
public WhenInterceptingAsynchronousResultMethodsWithNoDelay(ITestOutputHelper output) : base(output, 0)
{
}
}

public class WhenInterceptingAsynchronousResultMethodsWithADelay
: WhenInterceptingAsynchronousResultMethodsBase
{
public WhenInterceptingAsynchronousResultMethodsWithADelay() : base(10)
public WhenInterceptingAsynchronousResultMethodsWithADelay(ITestOutputHelper output) : base(output, 10)
{
}
}
Expand Down
Loading

0 comments on commit 6537e8f

Please sign in to comment.