Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ orbs:
name: Test Coverage
command: ./coverage.sh << parameters.framework >> << parameters.build-config >>
- store_artifacts:
path: ./test/TestResults/coverage.json
destination: coverage.json
- store_artifacts:
path: ./test/TestResults/coverage.opencover.xml
destination: coverage.opencover.xml
- store_artifacts:
path: ./test/TestResults/Report/
destination: report
path: ./test/TestResults/output/
destination: /
- store_test_results:
path: ./test/TestResults/output/

Expand Down
31 changes: 17 additions & 14 deletions coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ exe() { echo; echo "\$ $*" ; "$@" ; }
framework="${1-netcoreapp2.1}"
config="${2-Debug}"

testResults="test/TestResults"
include="[AutoTest.*]*"
exclude="\"[*.Tests]*,[AutoTest.ExampleLibrary]*\""

# Cannot use a bash solution in alpine builds https://stackoverflow.com/a/246128
#rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
rootDir=$(pwd)

testResults="test/TestResults"
output="$rootDir/$testResults/output"
tools="$rootDir/$testResults/tools"

testProj1="$rootDir/test/AutoTest.ExampleLibrary.Tests/AutoTest.ExampleLibrary.Tests.csproj"
testProj2="$rootDir/test/AutoTest.ArgumentNullException.Tests/AutoTest.ArgumentNullException.Tests.csproj"

Expand All @@ -28,42 +31,42 @@ exe dotnet build --no-restore -f "$framework" -c "$config" "$testProj2"
# Execute the tests
exe dotnet test --no-restore --no-build -f "$framework" -c "$config" \
"$testProj1" \
--results-directory "$rootDir/$testResults/output/" \
--results-directory "$output/" \
--logger "\"trx;LogFileName=$(basename "$testProj1" .csproj).trx\"" \
/p:CollectCoverage=true \
/p:Include="$include" \
/p:Exclude="$exclude" \
/p:CoverletOutput="$rootDir/$testResults/internal.coverage.json"
/p:CoverletOutput="$output/internal.coverage.json"

exe dotnet test --no-restore --no-build -f "$framework" -c "$config" \
"$testProj2" \
--results-directory "$rootDir/$testResults/output/" \
--results-directory "$output/" \
--logger "\"trx;LogFileName=$(basename "$testProj2" .csproj).trx\"" \
/p:CollectCoverage=true \
/p:Include="$include" \
/p:Exclude="$exclude" \
/p:MergeWith="$rootDir/$testResults/internal.coverage.json" \
/p:CoverletOutput="$rootDir/$testResults/" \
/p:MergeWith="$output/internal.coverage.json" \
/p:CoverletOutput="$output/" \
/p:CoverletOutputFormat="\"json,opencover\""

# Install trx2junit if not already installed
if [ ! -f "$rootDir/$testResults/tools/trx2junit" ]
if [ ! -f "$tools/trx2junit" ]
then
exe dotnet tool install trx2junit --tool-path "$rootDir/$testResults/tools"
exe dotnet tool install trx2junit --tool-path "$tools"
fi

# Install ReportGenerator if not already installed
if [ ! -f "$rootDir/$testResults/tools/reportgenerator" ]
if [ ! -f "$tools/reportgenerator" ]
then
exe dotnet tool install dotnet-reportgenerator-globaltool --tool-path "$rootDir/$testResults/tools"
exe dotnet tool install dotnet-reportgenerator-globaltool --tool-path "$tools"
fi

# Convert the MSTest trx files to junit xml
exe "$rootDir/$testResults/tools/trx2junit" "$rootDir/$testResults/output"/*.trx
exe "$tools/trx2junit" "$output"/*.trx

# Generate the reports
exe "$rootDir/$testResults/tools/reportgenerator" \
exe "$tools/reportgenerator" \
"-verbosity:Info" \
"-reports:$rootDir/$testResults/coverage.opencover.xml" \
"-targetdir:$rootDir/$testResults/Report" \
"-reports:$output/coverage.opencover.xml" \
"-targetdir:$output/Report" \
"-reporttypes:Html"
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ExcludeAllAttribute()
public override IArgNullExCustomization GetCustomization(MethodInfo method)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));

return this;
}
Expand All @@ -52,7 +52,7 @@ public override IArgNullExCustomization GetCustomization(MethodInfo method)
public virtual void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

if (ExclusionType.HasFlag(ExclusionType.Types))
fixture.ExcludeAllTypes();
Expand Down
4 changes: 2 additions & 2 deletions src/AutoTest.ArgumentNullException.Xunit/ExcludeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ExcludeAttribute : CustomizeAttribute, IArgNullExCustomization
public override IArgNullExCustomization GetCustomization(MethodInfo method)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));

return this;
}
Expand All @@ -61,7 +61,7 @@ public override IArgNullExCustomization GetCustomization(MethodInfo method)
public virtual void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

if (Type != null && !string.IsNullOrWhiteSpace(TypeFullName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ExcludePrivateAttribute : CustomizeAttribute, IArgNullExCustomizati
public override IArgNullExCustomization GetCustomization(MethodInfo method)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));

return this;
}
Expand All @@ -39,7 +39,7 @@ public override IArgNullExCustomization GetCustomization(MethodInfo method)
public virtual void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

fixture.ExcludePrivate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class IncludeAttribute : ExcludeAllAttribute
public override void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

if (Type != null && !string.IsNullOrWhiteSpace(TypeFullName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class MethodDataExtensions
public static Task Execute(this MethodData method)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));

return Assert.ThrowsAsync<ArgumentNullException>(method.NullParameter, method.ExecuteAction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ namespace AutoTest.ArgNullEx.Xunit
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RequiresArgumentNullExceptionAttribute : DataAttribute
{
/// <summary>
/// The fixture.
/// </summary>
private readonly IArgumentNullExceptionFixture _fixture;

/// <summary>
/// Initializes a new instance of the <see cref="RequiresArgumentNullExceptionAttribute"/> class.
/// </summary>
Expand All @@ -40,18 +35,15 @@ protected RequiresArgumentNullExceptionAttribute(
IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

_fixture = fixture;
Fixture = fixture;
}

/// <summary>
/// Gets the <see cref="IArgumentNullExceptionFixture"/>.
/// </summary>
public IArgumentNullExceptionFixture Fixture
{
get { return _fixture; }
}
public IArgumentNullExceptionFixture Fixture { get; }

/// <summary>
/// Returns the data for the test <see cref="TheoryAttribute"/>.
Expand All @@ -64,11 +56,11 @@ public IArgumentNullExceptionFixture Fixture
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
if (testMethod == null)
throw new ArgumentNullException("testMethod");
throw new ArgumentNullException(nameof(testMethod));

CustomizeFixture(testMethod, _fixture);
CustomizeFixture(testMethod, Fixture);

return _fixture.GetData().Select(data => new object[] { data });
return Fixture.GetData().Select(data => new object[] { data });
}

/// <summary>
Expand All @@ -81,7 +73,7 @@ public override IEnumerable<object[]> GetData(MethodInfo testMethod)
private static Assembly GetAssembly(Type assemblyUnderTest)
{
if (assemblyUnderTest == null)
throw new ArgumentNullException("assemblyUnderTest");
throw new ArgumentNullException(nameof(assemblyUnderTest));

return assemblyUnderTest.GetTypeInfo().Assembly;
}
Expand All @@ -96,9 +88,9 @@ private static Assembly GetAssembly(Type assemblyUnderTest)
private static void CustomizeFixture(MethodInfo method, IArgumentNullExceptionFixture fixture)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

IEnumerable<CustomizeAttribute> customizeAttributes =
method.GetCustomAttributes(typeof(CustomizeAttribute), inherit: false)
Expand Down
12 changes: 6 additions & 6 deletions src/AutoTest.ArgumentNullException.Xunit/SubstituteAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class SubstituteAttribute : CustomizeAttribute, IArgNullExCustomization
public SubstituteAttribute(Type originalType, Type newType)
{
if (originalType == null)
throw new ArgumentNullException("originalType");
throw new ArgumentNullException(nameof(originalType));
if (newType == null)
throw new ArgumentNullException("newType");
throw new ArgumentNullException(nameof(newType));

OriginalType = originalType;
NewType = newType;
Expand All @@ -35,12 +35,12 @@ public SubstituteAttribute(Type originalType, Type newType)
/// <summary>
/// Gets the original <see cref="Type"/> to be substituted by the <see cref="NewType"/>.
/// </summary>
public Type OriginalType { get; private set; }
public Type OriginalType { get; }

/// <summary>
/// Gets the new <see cref="Type"/> to substitute in place of the <see cref="OriginalType"/>.
/// </summary>
public Type NewType { get; private set; }
public Type NewType { get; }

/// <summary>
/// Gets a customization for a test method.
Expand All @@ -52,7 +52,7 @@ public SubstituteAttribute(Type originalType, Type newType)
public override IArgNullExCustomization GetCustomization(MethodInfo method)
{
if (method == null)
throw new ArgumentNullException("method");
throw new ArgumentNullException(nameof(method));

return this;
}
Expand All @@ -67,7 +67,7 @@ public override IArgNullExCustomization GetCustomization(MethodInfo method)
public void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

fixture.SubstituteType(OriginalType, NewType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ArgNullExCompositeCustomization : IArgNullExCustomization
public ArgNullExCompositeCustomization(IEnumerable<IArgNullExCustomization> customizations)
{
if (customizations == null)
throw new ArgumentNullException("customizations");
throw new ArgumentNullException(nameof(customizations));

_customizations = customizations.ToList();
}
Expand All @@ -42,10 +42,7 @@ public ArgNullExCompositeCustomization(params IArgNullExCustomization[] customiz
/// <summary>
/// Gets the customizations contained within this instance.
/// </summary>
public IEnumerable<IArgNullExCustomization> Customizations
{
get { return _customizations; }
}
public IEnumerable<IArgNullExCustomization> Customizations => _customizations;

/// <summary>
/// Customizes the specified fixture.
Expand All @@ -55,7 +52,7 @@ public IEnumerable<IArgNullExCustomization> Customizations
public void Customize(IArgumentNullExceptionFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
throw new ArgumentNullException(nameof(fixture));

_customizations.ForEach(customization => customization.Customize(fixture));
}
Expand Down
Loading