@@ -482,6 +482,64 @@ public void ExecutorShouldRunTestsWhenTestsAreCommaSeparatedWithEscape()
482482 Assert . AreEqual ( ArgumentProcessorResult . Success , argumentProcessorResult ) ;
483483 }
484484
485+ [ TestMethod ]
486+ public void ExecutorShouldDisplayWarningIfNoTestsAreExecuted ( )
487+ {
488+ var mockTestPlatform = new Mock < ITestPlatform > ( ) ;
489+ var mockTestRunRequest = new Mock < ITestRunRequest > ( ) ;
490+ var mockDiscoveryRequest = new Mock < IDiscoveryRequest > ( ) ;
491+ var mockTestRunStats = new Mock < ITestRunStatistics > ( ) ;
492+
493+ List < TestCase > list = new List < TestCase > ( ) ;
494+ list . Add ( new TestCase ( "Test1" , new Uri ( "http://FooTestUri1" ) , "Source1" ) ) ;
495+ list . Add ( new TestCase ( "Test2" , new Uri ( "http://FooTestUri2" ) , "Source2" ) ) ;
496+ mockDiscoveryRequest . Setup ( dr => dr . DiscoverAsync ( ) ) . Raises ( dr => dr . OnDiscoveredTests += null , new DiscoveredTestsEventArgs ( list ) ) ;
497+
498+ mockTestRunRequest . Setup ( tr => tr . ExecuteAsync ( ) ) . Returns ( 1 ) . Raises ( tr => tr . OnRunCompletion += null ,
499+ new TestRunCompleteEventArgs ( mockTestRunStats . Object , false , false , null , null , new TimeSpan ( ) ) ) ;
500+
501+ mockTestPlatform . Setup ( tp => tp . CreateTestRunRequest ( It . IsAny < IRequestData > ( ) , It . IsAny < TestRunCriteria > ( ) , It . IsAny < TestPlatformOptions > ( ) ) ) . Returns ( mockTestRunRequest . Object ) ;
502+ mockTestPlatform . Setup ( tp => tp . CreateDiscoveryRequest ( It . IsAny < IRequestData > ( ) , It . IsAny < DiscoveryCriteria > ( ) , It . IsAny < TestPlatformOptions > ( ) ) ) . Returns ( mockDiscoveryRequest . Object ) ;
503+
504+ this . ResetAndAddSourceToCommandLineOptions ( ) ;
505+ var testRequestManager = new TestRequestManager ( CommandLineOptions . Instance , mockTestPlatform . Object , TestRunResultAggregator . Instance , this . mockTestPlatformEventSource . Object , this . inferHelper , this . mockMetricsPublisherTask ) ;
506+ var executor = GetExecutor ( testRequestManager ) ;
507+
508+ executor . Initialize ( "Test1" ) ;
509+ executor . Execute ( ) ;
510+
511+ this . mockOutput . Verify ( op => op . WriteLine ( It . Is < string > ( st => st . Contains ( "Additionally, path to test adapters can be specified using /TestAdapterPath command." ) ) , OutputLevel . Warning ) , Times . Once ) ;
512+ }
513+
514+ [ TestMethod ]
515+ public void ExecutorShouldNotDisplayWarningIfTestsAreExecuted ( )
516+ {
517+ var mockTestPlatform = new Mock < ITestPlatform > ( ) ;
518+ var mockTestRunRequest = new Mock < ITestRunRequest > ( ) ;
519+ var mockDiscoveryRequest = new Mock < IDiscoveryRequest > ( ) ;
520+ var testRunStats = new TestRunStatistics ( 1 , new Dictionary < TestOutcome , long > { { TestOutcome . Passed , 1 } } ) ;
521+
522+ List < TestCase > list = new List < TestCase > ( ) ;
523+ list . Add ( new TestCase ( "Test1" , new Uri ( "http://FooTestUri1" ) , "Source1" ) ) ;
524+ list . Add ( new TestCase ( "Test2" , new Uri ( "http://FooTestUri2" ) , "Source2" ) ) ;
525+ mockDiscoveryRequest . Setup ( dr => dr . DiscoverAsync ( ) ) . Raises ( dr => dr . OnDiscoveredTests += null , new DiscoveredTestsEventArgs ( list ) ) ;
526+
527+ mockTestRunRequest . Setup ( tr => tr . ExecuteAsync ( ) ) . Returns ( 1 ) . Raises ( tr => tr . OnRunCompletion += null ,
528+ new TestRunCompleteEventArgs ( testRunStats , false , false , null , null , new TimeSpan ( ) ) ) ;
529+
530+ mockTestPlatform . Setup ( tp => tp . CreateTestRunRequest ( It . IsAny < IRequestData > ( ) , It . IsAny < TestRunCriteria > ( ) , It . IsAny < TestPlatformOptions > ( ) ) ) . Returns ( mockTestRunRequest . Object ) ;
531+ mockTestPlatform . Setup ( tp => tp . CreateDiscoveryRequest ( It . IsAny < IRequestData > ( ) , It . IsAny < DiscoveryCriteria > ( ) , It . IsAny < TestPlatformOptions > ( ) ) ) . Returns ( mockDiscoveryRequest . Object ) ;
532+
533+ this . ResetAndAddSourceToCommandLineOptions ( ) ;
534+ var testRequestManager = new TestRequestManager ( CommandLineOptions . Instance , mockTestPlatform . Object , TestRunResultAggregator . Instance , this . mockTestPlatformEventSource . Object , this . inferHelper , this . mockMetricsPublisherTask ) ;
535+ var executor = GetExecutor ( testRequestManager ) ;
536+
537+ executor . Initialize ( "Test1" ) ;
538+ executor . Execute ( ) ;
539+
540+ this . mockOutput . Verify ( op => op . WriteLine ( It . Is < string > ( st => st . Contains ( "Additionally, path to test adapters can be specified using /TestAdapterPath command." ) ) , OutputLevel . Warning ) , Times . Never ) ;
541+ }
542+
485543 #endregion
486544
487545 private void ResetAndAddSourceToCommandLineOptions ( )
0 commit comments