added parallel test execution support for ncrunch.

This commit is contained in:
kay.one 2013-01-19 12:59:36 -08:00
parent 130be58f8c
commit ff09773a3b
13 changed files with 70 additions and 23 deletions

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Autofac; using Autofac;
using FluentAssertions; using FluentAssertions;
using NCrunch.Framework;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
@ -15,6 +16,7 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
[TestFixture] [TestFixture]
[ExclusivelyUses("REAL_LOG_FILE")]
class CentralDispatchFixture : CoreTest class CentralDispatchFixture : CoreTest
{ {
readonly IList<string> indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).Select(c => c.ToString()).ToList(); readonly IList<string> indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).Select(c => c.ToString()).ToList();
@ -120,7 +122,7 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void quality_profile_initialized() public void quality_profile_initialized()
{ {
kernel.Resolve<QualityProvider>().All().Should().HaveCount(4); kernel.Resolve<QualityProvider>().All().Should().HaveCount(2);
} }
[Test] [Test]

View File

@ -16,7 +16,12 @@ namespace NzbDrone.Core.Test.Framework
{ {
internal static class TestDbHelper internal static class TestDbHelper
{ {
private const string DB_TEMPLATE_NAME = "_dbtemplate.sdf"; private static readonly string dbTemplateName;
static TestDbHelper()
{
dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf";
}
internal static string ConnectionString { get; private set; } internal static string ConnectionString { get; private set; }
@ -30,7 +35,7 @@ namespace NzbDrone.Core.Test.Framework
fileName = Guid.NewGuid() + ".sdf"; fileName = Guid.NewGuid() + ".sdf";
} }
File.Copy(DB_TEMPLATE_NAME, fileName); File.Copy(dbTemplateName, fileName);
ConnectionString = ConnectionFactory.GetConnectionString(fileName); ConnectionString = ConnectionFactory.GetConnectionString(fileName);
@ -46,7 +51,7 @@ namespace NzbDrone.Core.Test.Framework
internal static void CreateDataBaseTemplate() internal static void CreateDataBaseTemplate()
{ {
Console.WriteLine("Creating an empty PetaPoco database"); Console.WriteLine("Creating an empty PetaPoco database");
var connectionString = ConnectionFactory.GetConnectionString(DB_TEMPLATE_NAME); var connectionString = ConnectionFactory.GetConnectionString(dbTemplateName);
var database = ConnectionFactory.GetPetaPocoDb(connectionString); var database = ConnectionFactory.GetPetaPocoDb(connectionString);
database.Dispose(); database.Dispose();
} }

View File

@ -95,6 +95,10 @@
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> <Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath> <HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference> </Reference>
<Reference Include="NCrunch.Framework, Version=1.43.0.23, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\NCrunch.Framework.1.43.0.23\lib\net35\NCrunch.Framework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>

View File

@ -14,6 +14,7 @@
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration> <UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath> <ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<IgnoredTests> <IgnoredTests>
@ -26,5 +27,9 @@
<NamedTestSelector> <NamedTestSelector>
<TestName>NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests.ImportFileFixture.import_unparsable_file_should_skip</TestName> <TestName>NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests.ImportFileFixture.import_unparsable_file_should_skip</TestName>
</NamedTestSelector> </NamedTestSelector>
<RegexTestSelector>
<RegularExpression>NzbDrone\.Core\.Test\.Integeration\.ServiceIntegerationFixture\..*</RegularExpression>
</RegexTestSelector>
</IgnoredTests> </IgnoredTests>
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -8,6 +8,7 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" /> <package id="NBuilder" version="3.0.1.1" />
<package id="NCrunch.Framework" version="1.43.0.23" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" /> <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.0.12054" />

View File

@ -13,7 +13,9 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration /> <UseBuildConfiguration></UseBuildConfiguration>
<ProxyProcessPath /> <UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -13,7 +13,13 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration /> <UseBuildConfiguration></UseBuildConfiguration>
<ProxyProcessPath /> <UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<IgnoredTests>
<RegexTestSelector>
<RegularExpression>.*</RegularExpression>
</RegexTestSelector>
</IgnoredTests>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -31,7 +31,7 @@ namespace NzbDrone.Test.Common
protected Mock<RestProvider> MockedRestProvider { get; private set; } protected Mock<RestProvider> MockedRestProvider { get; private set; }
protected string VirtualPath private string VirtualPath
{ {
get get
{ {
@ -42,9 +42,15 @@ namespace NzbDrone.Test.Common
} }
} }
protected string TempFolder { get; private set; }
[SetUp] [SetUp]
public void TestBaseSetup() public void TestBaseSetup()
{ {
TempFolder = Path.Combine(Directory.GetCurrentDirectory(), "_temp_" + DateTime.Now.Ticks);
MockedRestProvider = new Mock<RestProvider>(); MockedRestProvider = new Mock<RestProvider>();
ReportingService.RestProvider = MockedRestProvider.Object; ReportingService.RestProvider = MockedRestProvider.Object;
ReportingService.SetupExceptronDriver(); ReportingService.SetupExceptronDriver();
@ -62,6 +68,18 @@ namespace NzbDrone.Test.Common
public void TestBaseTearDown() public void TestBaseTearDown()
{ {
_mocker = null; _mocker = null;
try
{
if (Directory.Exists(TempFolder))
{
Directory.Delete(TempFolder, true);
}
}
catch (Exception)
{
}
} }
protected void WithStrictMocker() protected void WithStrictMocker()
@ -80,12 +98,6 @@ namespace NzbDrone.Test.Common
.Returns(VirtualPath); .Returns(VirtualPath);
} }
protected string TempFolder
{
get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); }
}
protected string GetTestFilePath(string fileName) protected string GetTestFilePath(string fileName)
{ {
return Path.Combine(@".\Files\", fileName); return Path.Combine(@".\Files\", fileName);

View File

@ -14,6 +14,7 @@
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration> <UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath> <ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<IgnoredTests> <IgnoredTests>
@ -29,5 +30,8 @@
<NamedTestSelector> <NamedTestSelector>
<TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.SettingsPage</TestName> <TestName>NzbDrone.Web.UI.Automation.BasicPageFixture.SettingsPage</TestName>
</NamedTestSelector> </NamedTestSelector>
<RegexTestSelector>
<RegularExpression>.*</RegularExpression>
</RegexTestSelector>
</IgnoredTests> </IgnoredTests>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -13,7 +13,9 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration /> <UseBuildConfiguration></UseBuildConfiguration>
<ProxyProcessPath /> <UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -1,8 +1,8 @@
<SolutionConfiguration> <SolutionConfiguration>
<FileVersion>1</FileVersion> <FileVersion>1</FileVersion>
<AutoEnableOnStartup>True</AutoEnableOnStartup> <AutoEnableOnStartup>True</AutoEnableOnStartup>
<AllowParallelTestExecution>false</AllowParallelTestExecution> <AllowParallelTestExecution>true</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>false</AllowTestsToRunInParallelWithThemselves> <AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit> <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio> <FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec> <FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>

View File

@ -13,7 +13,9 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration /> <UseBuildConfiguration></UseBuildConfiguration>
<ProxyProcessPath /> <UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
</ProjectConfiguration> </ProjectConfiguration>

View File

@ -13,7 +13,9 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes> <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace> <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout> <DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration /> <UseBuildConfiguration></UseBuildConfiguration>
<ProxyProcessPath /> <UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture> <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
</ProjectConfiguration> </ProjectConfiguration>