Skip to content

Commit

Permalink
Add info log if try to run tests with no IsTestProject prop (#1778)
Browse files Browse the repository at this point in the history
* Add info log if try to run tests with no IsTestProject prop

* Add message to resources

* invert check
  • Loading branch information
smadala committed Oct 5, 2018
1 parent d5c4415 commit 3decca0
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/Microsoft.TestPlatform.Build/Microsoft.TestPlatform.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.BuildLogTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />

<!--
============================================================
Test target
Main entry point for running tests through vstest.console.exe
============================================================
-->
<Target Name="VSTest" Condition="'$(IsTestProject)' == 'true'">
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="BuildProject" />
<Target Name="VSTest" DependsOnTargets="ShowInfoMessageIfProjectHasNoIsTestProjectProperty">
<CallTarget Condition="'$(VSTestNoBuild)' != 'true' AND '$(IsTestProject)' == 'true'" Targets="BuildProject" />

<CallTarget Targets="ShowCallOfVSTestTaskWithParameter" />

Expand All @@ -48,15 +48,20 @@ Copyright (c) .NET Foundation. All rights reserved.
VSTestBlame="$(VSTestBlame)"
VSTestTraceDataCollectorDirectoryPath="$(TraceDataCollectorDirectoryPath)"
VSTestNoLogo="$(VSTestNoLogo)"
Condition="'$(IsTestProject)' == 'true'"
/>
</Target>

<Target Name="ShowInfoMessageIfProjectHasNoIsTestProjectProperty" Condition="'$(IsTestProject)' != 'true'">
<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="NoIsTestProjectProperty" ProjectFilePath="$(MSBuildProjectFullPath)" />
</Target>

<Target Name="BuildProject">
<CallTarget Targets="ShowMsbuildWithParameter" />

<Microsoft.TestPlatform.Build.Tasks.BuildLogTask BuildStarted="True" />
<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="BuildStarted" />
<MSBuild Projects ="$(MSBuildProjectFullPath)" />
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask />
<Microsoft.TestPlatform.Build.Tasks.VSTestLogsTask LogType="BuildCompleted" />

<Message Text="Done Building project $(MSBuildProjectFullPath) for TargetFramework=$(TargetFramework)" Importance="low" />
</Target>
Expand Down
11 changes: 10 additions & 1 deletion src/Microsoft.TestPlatform.Build/Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.TestPlatform.Build/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="BuildStarted" xml:space="preserve">
<value>Build started, please wait...</value>
</data>
<data name="NoIsTestProjectProperty" xml:space="preserve">
<value>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</value>
</data>
<data name="TestRunningSummary" xml:space="preserve">
<value>Test run for {0}({1})</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Upozornění: Aktualizujte odkaz na balíček Microsoft.NET.Test.Sdk na verzi 15.8.0 nebo novější, aby se získalo pokrytí kódu.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Warnung: Aktualisieren Sie die Microsoft.NET.Test.Sdk-Paketreferenz auf Version 15.8.0 oder höher, um von Code Coverage zu profitieren.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Advertencia: Actualice la referencia del paquete Microsoft.NET.Test.Sdk a la versión 15.8.0 o posterior para recopilar la cobertura de código.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Avertissement : mettez à jour la référence de package Microsoft.NET.Test.Sdk vers la version 15.8.0 ou ultérieure pour collecter la couverture du code.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Avviso: per raccogliere i dati di code coverage, aggiornare il riferimento al pacchetto Microsoft.NET.Test.Sdk alla versione 15.8.0 o successiva.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">警告: コード カバレッジを収集するには、Microsoft.NET.Test.Sdk パッケージ参照をバージョン 15.8.0 以降に更新してください。</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">경고: 코드 검사를 수집하려면 Microsoft.NET.Test.Sdk 패키지 참조를 버전 15.8.0 이상으로 업데이트하세요.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Ostrzeżenie: zaktualizuj odwołanie do pakietu Microsoft.NET.Test.Sdk do wersji 15.8.0 lub nowszej w celu zbierania danych dotyczących pokrycia kodu.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Aviso: Atualize a referência do pacote Microsoft.NET.Test.Sdk para a versão 15.8.0 ou posterior para coletar a cobertura do código.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Внимание. Для сбора данных об объеме протестированного кода обновите пакет Microsoft.NET.Test.Sdk по ссылке как минимум до версии 15.8.0.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">Uyarı: Kod kapsamını toplamak için Microsoft.NET.Test.Sdk paketinin başvurusunu 15.8.0 veya üzeri bir sürüme güncelleştirin.</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions src/Microsoft.TestPlatform.Build/Resources/xlf/Resources.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<target state="new">To collect code coverage update Microsoft.NET.Test.Sdk package version to latest.</target>
<note></note>
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">警告: 将 Microsoft.NET.Test.Sdk 包引用更新为版本 15.8.0 或更高版本,以便收集代码覆盖率。</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<target state="translated">警告: 將 Microsoft.NET.Test.Sdk 套件參考更新至版本 15.8.0 或更新版本,才可收集程式碼涵蓋範圍。</target>
<note />
</trans-unit>
<trans-unit id="NoIsTestProjectProperty">
<source>Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</source>
<target state="new">Skipping running test for project {0}. To run tests with dotnet test add "&lt;IsTestProject&gt;true&lt;IsTestProject&gt;" property to project file.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,40 @@ namespace Microsoft.TestPlatform.Build.Tasks
using Microsoft.Build.Utilities;
using Microsoft.TestPlatform.Build.Resources;

public class BuildLogTask : Task
public class VSTestLogsTask : Task
{
public bool BuildStarted
public string LogType
{
get;
set;
}

public string ProjectFilePath
{
get;
set;
}

public override bool Execute()
{
if (BuildStarted)
if (string.Equals(LogType, "BuildStarted", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(Resources.BuildStarted);
}
else
else if (string.Equals(LogType, "BuildCompleted", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(Resources.BuildCompleted);
Console.WriteLine();
}
else if (string.Equals(LogType, "NoIsTestProjectProperty", StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine(Resources.NoIsTestProjectProperty, ProjectFilePath);
}
else
{
return false;
}

return true;
}
}
Expand Down

0 comments on commit 3decca0

Please sign in to comment.