如何在单次测试中多次执行单元测试?

时间:2021-12-04 01:24:03

One of my tests is intermittently failing. I now want to execute the test frequently.

我的一项测试是间歇性失败。我现在想经常执行测试。

I wrote a little batch file

我写了一个小批处理文件

:loop
mstest /testcontainer:"path/test.dll" /test:"mytest"
set /a COUNT=%COUNT%+1
if %COUNT GTR %MAX% goto end
goto loop

While this works fine, though the output isn't meaningful or telling. Let's assume I run this test 100 times I get 100 times a text saying

虽然这很好,但输出没有意义或说明。让我们假设我运行此测试100次,我得到100次文本说

Loading ... 
Starting execution ...
Results
Passed/Failed 1
--------
Total 1

And 100 .trx files will be created...

并将创建100个.trx文件...

What I actually want is having an output like this

我真正想要的是拥有这样的输出

Passed 97
Failed 3
--------
Total 100

and just one .trx file.

只有一个.trx文件。

I somehow doubt that it's possible to run a test several times in a single test run at all since I didn't find any parameter on mstest /help output.

我怀疑在一次测试运行中可能会多次运行测试,因为我没有在mstest / help输出上找到任何参数。

Is there a way to create an output as close as possible to the given request?

有没有办法尽可能接近给定的请求创建输出?

1 个解决方案

#1


0  

setlocal enabledelayedexpansion
set passed=0
set failed=0
for /l %%x in (1,1,%max%) do (
  mstest /testcontainer:"path/test.dll" /test:"mytest"
  if !errorlevel!==0 (
    set /a passed=passed+1
  ) else (
    set /a failed=failed+1
  )
)
echo Passed %passed% > %~n1.trx
echo Failed %failed% >> %~n1.trx
echo --------- >> %~n1.trx
echo Total %Max% >> %~n1.trx
endlocal

#1


0  

setlocal enabledelayedexpansion
set passed=0
set failed=0
for /l %%x in (1,1,%max%) do (
  mstest /testcontainer:"path/test.dll" /test:"mytest"
  if !errorlevel!==0 (
    set /a passed=passed+1
  ) else (
    set /a failed=failed+1
  )
)
echo Passed %passed% > %~n1.trx
echo Failed %failed% >> %~n1.trx
echo --------- >> %~n1.trx
echo Total %Max% >> %~n1.trx
endlocal