mstest


How to explicitly exit Data driven test method in MSTest


I use Data driven testing feature in MS test framework. [DataSource] attribute specifies table. C# Method is marked as [TestMethod]. It works but sometimes I need to stop execution. For example, table has 100 rows. How to explicitly (prematurely) exit test method (stop the rest of DDT invocations) after some condition, say during invocation of this method for 50-th row?
[DataSource("System.Data.SQLite", #"Data Source=D:\Test.db;", "TestTableName",
DataAccessMethod.Sequential)]
[TestMethod]
public void DataTest()
{
string userId = Convert.ToString(TestContext.DataRow["userid"]);
string telephone = Convert.ToString(TestContext.DataRow["telephone"]);
string email = Convert.ToString(TestContext.DataRow["email"]);
// .....
functionThatPerformsAssert(userId, telephone, email);
// .....
}
I solved this invoking Assert.Inconclusive from functionThatPerformsAssert() where _skipTest determines whether to skip current row in data driven test and begin next row:
if (_skipTest)
Assert.Inconclusive("Test Skipped");

Related Links

Mstest name instead Data Row with Data-Driven testing
How to unit test a class defined in a Metro executable
local.testsettings file that is sensitive to configuration
Can't run Unit Tests In VS2012RC
assemblybinding does not work in mstest
what is the equivalant to MbUnit.Framework.RowAttribute in MSTest?
MSTest: A sensible way to deploy items from a common directory?
Adding Unit Test Project to ASP.Net MVC 4 Project
What is the major difference between Pex vs MsTest?
What is the significance of the red outline in a failed Coded UI test screenshot?
MS Test, Multiple Test Projects in Solution, and DeploymentItemAttribute
Print MSTest summary after command line exeution
How do you get the iteration / line number from TestContext in data driven tests?
How to refresh UIMap object in CodedUI
No mole class for NativeMethods.cs?
Find All Tests Not in a List

Categories

HOME
cheerio
polymer
depth
youtube-data-api-v3
mysql-workbench
hessian
sublimetext
access
yandex
spring-data-mongodb
mips
regular-language
nuget-package
android-json
mvc5
nfs
rcloud
accessibility
sendgrid-api-v3
arangodb
shared-libraries
qsqlquery
heat
entitymanager
job-scheduling
xmonad
symfony-console
sar
breadth-first-search
backpack-for-laravel
resourcebundle
google-api-client
windows-server-2003
itunes
8051
wcag
sqlpackage
zend-debugger
glib
git-squash
wacom
contacts
lubridate
xajax
android-augmented-reality
mcustomscrollbar
optimizely
term
linter
mongotemplate
google-cse
payara-micro
custom-font
pdf-conversion
gameplay-kit
smartfoxserver
cronexpression
chromium-os
usart
atlas
ziparchive
envi
angular-ui-typeahead
redis-cluster
findfirst
pushbots
video-player
doctype
rrule
grouping-sets
ejb-2.x
angular-gettext
appserver
lambda-architecture
ray
jquery-slider
vsx
menubar
spring-3
gd-graph
breakout
code-duplication
windows-phone-8-sdk
cmmi
dolby-audio-api
tree-balancing
extconf.rb
inkcanvas
pinch
jquery-tools
rmdir
dataform
unattended-processing
web-garden
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App