Skip to content

Commit

Permalink
added dedicated settings demonstration file, made solution settings f…
Browse files Browse the repository at this point in the history
…ile more realistic
  • Loading branch information
csoltenborn committed Nov 16, 2015
1 parent 42c1d17 commit e9ffb0f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
20 changes: 20 additions & 0 deletions GoogleTestExtension/Resources/AllTestSettings.gta.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<GoogleTestAdapter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<AdditionalTestExecutionParam>-testdirectory=$(TestDir)</AdditionalTestExecutionParam>
<BatchForTestSetup>Tests\Returns0.bat</BatchForTestSetup>
<BatchForTestTeardown>Tests\Returns1.bat</BatchForTestTeardown>
<DebugMode>false</DebugMode>
<MaxNrOfThreads>4</MaxNrOfThreads>
<NrOfTestRepetitions>1</NrOfTestRepetitions>
<ParallelTestExecution>false</ParallelTestExecution>
<PrintTestOutput>true</PrintTestOutput>
<ReportWaitPeriod>10</ReportWaitPeriod>
<RunDisabledTests>false</RunDisabledTests>
<ShuffleTests>false</ShuffleTests>
<ShuffleTestsSeed>0</ShuffleTestsSeed>
<TestDiscoveryRegex>.*Tests.*.exe</TestDiscoveryRegex>
<TraitsRegexesAfter></TraitsRegexesAfter>
<TraitsRegexesBefore />
</GoogleTestAdapter>
</RunSettings>
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Google Test Adapter (GTA) is a Visual Studio extension providing test discovery
Google Test Adapter can be installed in two ways:

* Install through the Visual Studio Gallery at *Tools/Extensions and Updates* - search for *Google Test Adapter*. This will make sure that the extension is updated automatically
* Download and launch the [VSIX installer](https://github.com/csoltenborn/GoogleTestAdapter/releases/download/v0.2/GoogleTestAdapter-0.2.0.vsix) (which can also be downloaded from the [Visual Studio Gallery](https://visualstudiogallery.msdn.microsoft.com/94c02701-8043-4851-8458-34f137d10874))
* Download and launch the [VSIX installer](https://github.com/csoltenborn/GoogleTestAdapter/releases/download/v0.2.1/GoogleTestAdapter-0.2.1.vsix) (which can also be downloaded from the [Visual Studio Gallery](https://visualstudiogallery.msdn.microsoft.com/94c02701-8043-4851-8458-34f137d10874))

After restarting VS, your tests will be displayed in the test explorer at build completion time. If no or not all tests show up, switch on *Debug mode* at *Tools/Options/Google Test Adapter/General*, which will show on the test console whether your test executables are recognized by GTA. If they are not, configure a *Test discovery regex* at the same place.

Expand All @@ -38,10 +38,10 @@ After restarting VS, your tests will be displayed in the test explorer at build
GTA is configured following Visual Studio's approach of configuration inheritance. There are three configuration levels:

1. Global options are configured in *Tools/Options/Google Test Adapter*.
2. Solution specific options override global options. They are provided by means of an XML configuration file; this allows sharing of settings via source control. The configuration file must be placed in the same folder as the solution's `.sln` file, and must have the same name as that file, but with extension `.gta.runsettings`. E.g., if the solution file's name is `Foo.sln`, the settings file must be named `Foo.gta.runsettings`. As a start, you can download a [sample solution test settings file](https://raw.githubusercontent.com/csoltenborn/GoogleTestAdapter/master/SampleGoogleTestTests/SampleGoogleTestTests.gta.runsettings).
3. Finally, VS allows for the selection of [test settings](https://msdn.microsoft.com/en-us/library/jj635153.aspx) files via the *Test/Test Settings* menu. GTA test settings can be added to an existing `.runsettings` file by adding a `GoogleTestAdapter` node to the `RunSettings` node of the file; such settings override global and solution settings.
2. Solution specific options override global options. They are provided by means of an XML configuration file; this allows sharing of settings via source control. The configuration file must be placed in the same folder as the solution's `.sln` file, and must have the same name as that file, but with extension `.gta.runsettings`. E.g., if the solution file's name is `Foo.sln`, the settings file must be named `Foo.gta.runsettings`. As a start, you can download a [sample solution test settings file](https://raw.githubusercontent.com/csoltenborn/GoogleTestAdapter/master/Resources/AllTestSettings.gta.runsettings). A realistic example is provided as part of the SampleGoogleTestTests solution.
3. Finally, VS allows for the selection of [test settings](https://msdn.microsoft.com/en-us/library/jj635153.aspx) files via the *Test/Test Settings* menu. GTA test settings can be added to an existing `.runsettings` file by adding a `GoogleTestAdapter` node to the `RunSettings` node of the file; such settings override global and solution settings. A sample file `NonDeterministic.runsettings` is provided as part of the SampleGoogleTestTests solution.

Note that due to the overriding hierarchy described above, you probably want to provide only a subset of the nodes under `GoogleTestAdapter` in your configuration files. For instance, providing the node `<DebugMode>true</DebugMode>` in a shared solution settings file will make sure that all sharing developers will run GTA with debug output, no matter what the developer's individual settings at *Tools/Options/Google Test Adapter* are (and unless the developer has selected a test settings file via VS which again overrides that setting).
Note that due to the overriding hierarchy described above, you probably want to provide only a subset of the nodes under `GoogleTestAdapter` in your configuration files. For instance, providing the node `<DebugMode>true</DebugMode>` in a shared solution settings file will make sure that all sharing developers will run GTA with debug output, no matter what the developer's individual settings at *Tools/Options/Google Test Adapter* are (and unless the developer has selected a test settings file via VS, which would override the solution setting).

#### Assigning traits to tests

Expand Down
2 changes: 2 additions & 0 deletions SampleGoogleTestTests/NonDeterministic.runsettings
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<GoogleTestAdapter>
<ShuffleTests>true</ShuffleTests>
<NrOfTestRepetitions>5</NrOfTestRepetitions>
<BatchForTestTeardown>Tests\Returns0.bat</BatchForTestTeardown>
</GoogleTestAdapter>
</RunSettings>
13 changes: 1 addition & 12 deletions SampleGoogleTestTests/SampleGoogleTestTests.gta.runsettings
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<GoogleTestAdapter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GoogleTestAdapter>
<AdditionalTestExecutionParam>-testdirectory=$(TestDir)</AdditionalTestExecutionParam>
<BatchForTestSetup>Tests\Returns0.bat</BatchForTestSetup>
<BatchForTestTeardown>Tests\Returns1.bat</BatchForTestTeardown>
<DebugMode>false</DebugMode>
<MaxNrOfThreads>4</MaxNrOfThreads>
<NrOfTestRepetitions>1</NrOfTestRepetitions>
<ParallelTestExecution>false</ParallelTestExecution>
<PrintTestOutput>true</PrintTestOutput>
<ReportWaitPeriod>10</ReportWaitPeriod>
<RunDisabledTests>false</RunDisabledTests>
<ShuffleTests>false</ShuffleTests>
<ShuffleTestsSeed>0</ShuffleTestsSeed>
<TestDiscoveryRegex>.*Tests.*.exe</TestDiscoveryRegex>
<TraitsRegexesAfter></TraitsRegexesAfter>
<TraitsRegexesBefore />
</GoogleTestAdapter>
</RunSettings>

0 comments on commit e9ffb0f

Please sign in to comment.