Microsoft Pex - First Look
- Pex generate codes with Unit Test project.
- pexwizard.exe
pexwizard.exe /o:D:\PexTest\PexTest.Samples.Tests /testf:nunit D:\PexTest\PexTest.Samples\bin\Debug\PexTest.Samples.dll
- Results:
CopyFilesToOutputDirectory:
PexTest.Samples -> D:\PexTest\PexTest.Samples\bin\Debug\PexTest.Samples.dll
Done Building Project "D:\PexTest\PexTest.Samples\PexTest.Samples.csproj" (default targets).
Build:
Pex Test Generator Wizard v0.90.50303.0 on .net 2.0.0.0
(c) Microsoft Corporation. All rights reserved.
output directory: D:\PexTest\PexTest.Samples.Tests
loading D:\PexTest\PexTest.Samples\bin\Debug\PexTest.Samples.dll
from D:\PexTest\PexTest.Samples\bin\Debug\PexTest.Samples.dll
visibility: exported or assembly(PexTest.Samples.Tests)
Processing 1 types
Processing PexTest.Samples
Scanning assembly references in PexTest.Samples
Applying template AssemblyInfo to PexTest.Samples
Applying template Tests to PexTest.Samples
test stubbing StringHelper -> StringHelperTest
generating method bodies
flushing generated code
updating assembly references
Compiling generated tests
Test project successfully compiled at D:\PexTest\PexTest.Samples.Tests\bin\Debug\PexTest.Samples.Tests.dll
The wizard has created parameterized unit test stubs.
Please edit the stubs if you wish to add more assertions.
You can let Pex generate the actual unit tests from the stubs with the following command-line:
C:\Program Files (x86)\Microsoft Pex\bin\pex.exe D:\PexTest\PexTest.Samples.Tests\bin\Debug\PexTest.Samples.Tests.dll /nologo /donotopenreport /testprojectfile:D:\PexTest\PexTest.Samples.Tests\PexTest.Samples.Tests.csproj
- "Create Parameterized Unit Tests" can generate a new project, but it no way to update exist file, only overwrite.
- An article describe here: Test Project generation
- Run Pex Explorations
C:\Program Files (x86)\Microsoft Pex\bin\pex.exe pex.x86.exe D:\PexTest\PexTest.Samples.Tests\bin\Debug\PexTest.Samples.Tests.dll
- Result:
Microsoft Pex v0.90.50303.0 -- http://research.microsoft.com/pex
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.
instrumenting... launched Pex 0.90.50303.0 x64/IA64 Edition on .NET v2.0.50727
This version of Pex does not support x64/IA64. Pex will restart as x86 process.
(Consider using command-line option /x86 to avoid restart.)
Microsoft Pex v0.90.50303.0 -- http://research.microsoft.com/pex
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.
instrumenting... launched Pex 0.90.50303.0 x86 Edition on .NET v2.0.50727
00:00:00.0> starting execution
00:00:00.0> reflecting tests
00:00:00.5> PexTest.Samples.Tests
00:00:00.5> StringHelperTest
00:00:00.5> ReplaceFirst(String, Char)
[test] (run 1) ReplaceFirstThrowsNullReferenceException939 (new), NullReferenceException: Object reference not set to an instance of an object.
[coverage] coverage increased from 0 to 1 blocks (+1) after flipping __InstrumentedSummarizers.System.String.Substring at 0x0001
[symbols] could not load symbols for C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
[symbols] search path: ;
[test] (run 2) ReplaceFirstThrowsArgumentOutOfRangeException391 (new), ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex
[test] (run 3) ReplaceFirst406 (new)
[coverage] coverage increased from 1 to 3 blocks (+2) after flipping __InstrumentedSummarizers.System.String.Substring at 0x0034
[dynamic coverage] 3/3 block (100.00%)
00:00:02.7> [finished] execution time 00:00:02.7201556.
-- 0 critical errors, 0 errors, 0 warnings.
-- 3 generated tests, 2 failing, 3 new, 0 inconclusive.
[coverage] skipping coverage reports...
[reports] skipping html reports
EXPLORATION SUCCESS
Test project : https://files.cnblogs.com/kevinzx/PexTest.rar