Skip to content

Commit

Permalink
fix: Remove [Test] attribute from SpecificationSource method
Browse files Browse the repository at this point in the history
This fix corrects an issue with updated test runners (e.g. the Visual
Studio Test Runner & Resharper) where multiple instances of the same
test appear within the discovered suite resulting in varying aberrant
results.
  • Loading branch information
Derek Greer committed Apr 23, 2019
1 parent 7e3075f commit 2bc6a25
Show file tree
Hide file tree
Showing 10 changed files with 1,176 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ TestResults/
PrecompiledWeb/
build/CommonAssemblyInfo.cs
src/packages/
**/.vs
artifacts
lib
*.gpState
Expand Down
61 changes: 61 additions & 0 deletions build-pre-release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@echo off
set FIND=C:\Windows\System32\find.exe
set SUFFIX=%1

FOR /F "tokens=4,* USEBACKQ" %%G IN (`npx standard-version --dry-run ^| %FIND% "tagging"`) DO SET PRE_RELEASE_VERSION=%%G

IF "%PRE_RELEASE_VERSION:~0,1%"=="v" (
set PRE_RELEASE_VERSION=%PRE_RELEASE_VERSION:~1%
)

if "%1"=="" (
set SUFFIX=alpha
)

setlocal EnableDelayedExpansion
WHERE yarn >nul 2>&1
set YARN_AVAILABLE=%ERRORLEVEL%

WHERE npm >nul 2>&1
set NPM_AVAILABLE=%ERRORLEVEL%

IF "%YARN_AVAILABLE%" NEQ "0" (
ECHO The yarn command is not available.
IF "%NPM_AVAILABLE%" EQU "0" (
SET /P "Input=Would you like to use npm to install yarn? (y/n):"
IF "!Input!"=="y" (
call npm install yarn -g
goto build
) else (
GOTO error
)
) else (
GOTO :error
)
)

REM Check that the version of standard-version supports dry-run
call npx standard-version --help | %FIND% "dry-run" 1> nul 2> nul
IF "%ERRORLEVEL%" NEQ "0" (
GOTO :standardVersionError
)

:build
ECHO Building Prelease Version: %PRE_RELEASE_VERSION%-%SUFFIX%
call yarn
REM call yarn run setVersionSuffix %SUFFIX%
REM call yarn run build:pre-release
set "PreReleaseVersion=%PRE_RELEASE_VERSION%" & set "VersionSuffix=%SUFFIX%" & yarn run build:pre-release
GOTO end

:error
ECHO Please run %~n0%~x0 again after installing yarn.

:standardVersionError
ECHO Please install the latest version of standard-version (see https://github.com/conventional-changelog/standard-version)
ECHO.
GOTO end

:end


24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@
"scripts": {
"prebuild": "npm run clean",
"clean": "rimraf dist",
"build": "npm-run-all build:* tests package",
"build:restore": "cross-env globstar -- ${npm_package_dotnetPath} restore \"**/*.sln\" /p:Version=${npm_package_version}",
"build:build": "cross-env globstar -- ${npm_package_dotnetPath} build \"**/*.sln\" --configuration ${npm_package_configuration} /p:Version=${npm_package_version}",
"build": "npm-run-all build:restore build:build tests package",
"build:restore": "cross-env-shell globstar -- ${npm_package_dotnetPath} restore \"**/*.sln\" /p:Version=${npm_package_version}",
"build:build": "cross-env-shell globstar -- ${npm_package_dotnetPath} build \"**/*.sln\" --configuration ${npm_package_configuration} /p:Version=${npm_package_version}",
"build:pre-release": "npm-run-all build:pre-release:restore build:pre-release:build tests package:pre-release",
"build:pre-release:restore": "cross-env-shell globstar -- ${npm_package_dotnetPath} restore \"**/*.sln\" /p:Version=${PreReleaseVersion}",
"build:pre-release:build": "cross-env-shell globstar -- ${npm_package_dotnetPath} build \"**/*.sln\" --configuration ${npm_package_configuration} /p:Version=${PreReleaseVersion}",
"tests": "npm-run-all tests:*",
"tests:core": "cross-env globstar -- ${npm_package_dotnetPath} test --configuration ${npm_package_configuration} \"src/${npm_package_name}.Specs/*.csproj",
"tests:net452": "cross-env globstar -- ${PWD}/src/packages/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe \"src/${npm_package_name}.Net452.Specs/bin/${npm_package_configuration}/*.Specs.dll",
"package": "npm-run-all package:*",
"package:main": "cross-env globstar -- ${npm_package_dotnetPath} pack \"./src/**/${npm_package_name}.csproj\" -c ${npm_package_configuration} --no-build -o ../../dist --include-symbols /p:Version=${npm_package_version}",
"tests:core": "cross-env-shell globstar -- ${npm_package_dotnetPath} test --configuration ${npm_package_configuration} \"src/${npm_package_name}.Specs/*.csproj",
"tests:net452": "cross-env-shell globstar -- ${PWD}/src/packages/NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe \"src/${npm_package_name}.Net452.Specs/bin/${npm_package_configuration}/*.Specs.dll",
"package": "npm-run-all clean package:release:*",
"package:release:main": "cross-env-shell globstar -- ${npm_package_dotnetPath} pack \"./src/**/${npm_package_name}.csproj\" -c ${npm_package_configuration} --no-build -o ../../dist --include-symbols /p:Version=${npm_package_version}",
"package:pre-release": "npm-run-all clean package:pre-release:*",
"package:pre-release:main": "cross-env-shell globstar -- ${npm_package_dotnetPath} pack --version-suffix ${VersionSuffix} \"./src/**/${npm_package_name}.csproj\" -c ${npm_package_configuration} --no-build -o ../../dist --include-symbols -p:VersionPrefix=${PreReleaseVersion}",
"publish": "npm-run-all publish:*",
"publish:main": "cross-env globstar -- ${npm_package_dotnetPath} nuget push dist/${npm_package_name}.${npm_package_version}.nupkg --source ${npm_package_publishSource}"
"publish:main": "cross-env-shell globstar -- ${npm_package_dotnetPath} nuget push \"dist/${npm_package_name}.*.nupkg\" --source ${npm_package_publishSource}"
},
"keywords": [
"logging"
Expand All @@ -26,7 +31,7 @@
"dependencies": {},
"devDependencies": {
"cpx": "^1.5.0",
"cross-env": "^4.0.0",
"cross-env": "^5.0.2",
"cross-run": "^1.0.1",
"download-cli": "^1.0.1",
"extend": "^3.0.0",
Expand All @@ -37,6 +42,7 @@
"path": "^0.12.7",
"request": "^2.81.0",
"rimraf": "^2.6.1",
"standard-version": "^5.0.2",
"tmp": "^0.0.31",
"which": "^1.2.14"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.props" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.props')" />
<Import Project="..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.props" Condition="Exists('..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.props')" />
<Import Project="..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -12,6 +16,8 @@
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,8 +37,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
<Reference Include="Microsoft.VisualStudio.CodeCoverage.Shim, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeCoverage.16.0.1\lib\net45\Microsoft.VisualStudio.CodeCoverage.Shim.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Should, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Should.1.1.20\lib\Should.dll</HintPath>
Expand Down Expand Up @@ -65,4 +74,17 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.13.0\build\net35\NUnit3TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.targets" Condition="Exists('..\packages\Microsoft.CodeCoverage.16.0.1\build\netstandard1.0\Microsoft.CodeCoverage.targets')" />
<Import Project="..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.targets" Condition="Exists('..\packages\Microsoft.NET.Test.Sdk.16.0.1\build\net40\Microsoft.NET.Test.Sdk.targets')" />
</Project>
8 changes: 0 additions & 8 deletions src/NUnit.Specifications.Net452.Specs/app.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="2638cd05610744eb" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.6.1.0" newVersion="3.6.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
11 changes: 6 additions & 5 deletions src/NUnit.Specifications.Net452.Specs/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NET.Test.Sdk" version="15.0.0" targetFramework="net462" />
<package id="Microsoft.TestPlatform.TestHost" version="15.0.0" targetFramework="net462" />
<package id="NUnit" version="3.6.1" targetFramework="net462" />
<package id="NUnit.ConsoleRunner" version="3.6.1" targetFramework="net452" />
<package id="NUnit3TestAdapter" version="3.7.0" targetFramework="net462" />
<package id="Microsoft.CodeCoverage" version="16.0.1" targetFramework="net452" />
<package id="Microsoft.NET.Test.Sdk" version="16.0.1" targetFramework="net452" />
<package id="Microsoft.TestPlatform.TestHost" version="16.0.1" targetFramework="net452" />
<package id="NUnit" version="3.11.0" targetFramework="net452" />
<package id="NUnit.ConsoleRunner" version="3.10.0" targetFramework="net452" />
<package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net452" />
<package id="Should" version="1.1.20" targetFramework="net452" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.7.10" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0-ci-00459-pr-313" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion src/NUnit.Specifications/ContextSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public IEnumerable GetObservations()
}
}

[Test]
[SpecificationSource("GetObservations")]
public void Observations(It observation)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NUnit.Specifications/NUnit.Specifications.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageTags>bdd tdd testing</PackageTags>
<PackageProjectUrl>https://github.com/derekgreer/nunit.specifications/</PackageProjectUrl>
<PackageIconUrl>https://github.com/derekgreer/nunit.specifications/raw/master/images/ico.png</PackageIconUrl>
<PackageLicenseUrl>https://github.com/derekgreer/nunit.specifications/raw/master/license.txt</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/derekgreer/nunit.specifications/</RepositoryUrl>
Expand Down
Loading

0 comments on commit 2bc6a25

Please sign in to comment.