2017-11-27 4 views
0

reportFilePathを変数に設定しているときに返されるすべてのデータセットに対して1番目と2番目のテストを実行したい毎回。私はそれだけで一つのテストを作ることができますが、私はここで C#Nunit - yieldデータを返すときに2つのテストを並行して実行する

private string reportFilePath; 

[Test] 
[TestCaseSource(typeof(TestData.SwiftReporting), "GenerateDailyLargeExposureReport")] 
[Order(4)] 
public async Task ShouldGenerateDailyLargeExposureReport(int year, int month, int day) 
    { 
     ReportResponseModel dailyLargeExposureReport = new ReportResponseModel(); 

     DateTime date = new DateTime(year, month, day).Date; 
     string formattedDate = date.ToString("d"); 

     dailyLargeExposureReport = await ReportLogic.RequestReport(date, (int)ReportsEnum.DailyLargeExposureReport, null, AuthToken); 
     dailyLargeExposureReport.Should().NotBeNull(); 
     reportFilePath = dailyLargeExposureReport.FilePath; 
    } 


[Test] 
[TestCaseSource(typeof(TestData.SwiftReporting), "DownloadDailyLargeExposureReport")] 
[Order(8)] 
public async Task ShouldDownloadDailyLargeExposureReport(int accountCount) 
    { 
     DailyLargeExposureReportModel outputReport = new DailyLargeExposureReportModel(); 
     outputReport = (DailyLargeExposureReportModel)await ReportLogic.DownloadReport(reportFilePath, ReportsEnum.DailyLargeExposureReport, AuthToken); 

     List<DailyLargeExposureAccountModel> reportAccounts = outputReport.Accounts; 
     reportAccounts.Count().Should().Be(7); 
    } 

が私のデータである大きすぎるのthatsを考える:それから、

public static IEnumerable<TestCaseData> GenerateDailyLargeExposureReport 
    { 
     get 
     { 
      yield return new TestCaseData(2017, 1, 2) 
       .SetName("Generate DLE report for Account1, Jan 2"); 
      yield return new TestCaseData(2017, 1, 3) 
       .SetName("Generate DLE report for Account1, Jan 3"); 
     } 
    } 

public static IEnumerable<TestCaseData> DownloadDailyLargeExposureReport 
    { 
     get 
     { 
      yield return new TestCaseData(3) 
       .SetName("Get data for Account1, Jan 2"); 
      yield return new TestCaseData(5) 
       .SetName("Get data for Account1, Jan 3"); 
     } 
    } 

は、だから私は、それぞれのIEnumerableにデータの最初のセットのための両方のテストを実行したいです2番目のセットでもう一度やり直してください。

答えて

0

申し訳ありませんが、両方の方法に[Parallelizable]を追加しない限り、これを行うことはできません。しかし、これは4つのテストすべてを並行して実行することを可能にします。これはあなたが望むものではありません。

これを再構成する方法の1つは、TestFixtureSourceAttributeを使用して2つのテストを含むパラメータ化されたフィクスチャを作成することです。フィクスチャインスタンスを並列化できないようにして、それらが一緒に実行されないようにすることもできますが、個々のテストはパラレル化可能にすることができます。

関連する問題