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

Can you Profile Ms test integration tests?
How to get MSTest to work with Gallio/MBUnit?
How to get MSTest to find my test data files?
How to use Microsoft built in Tests with NHibernate For Repository Layer(DAL)?
MS Test Project - Accessor not working properly across assemblies
Is there a more robust way to integration test my persistance layer app.config?
Why PartCover report shows 0% when mstest runs successfully and all tests pass
Relative paths with NCover and MSTest.exe
MSTest doesn't find tests when switching from MbUnit to MSTest
mstest failing to start
MSTest run fails because source assembly is not trusted
What is needed to execute visual studio 2005 web tests?
Can MSTest run a specific method each time it startsup?
How can I emulate MbUnit's [MultipleCulture] attribute in MSTest?
MSTest and custom messages
Integrating MSTest with Cruise control for multiple projects

Categories

HOME
asp.net-web-api
search
obfuscation
jelastic
visual-studio-emulator
google-admin-sdk
azure-container-service
gluon-mobile
fabric.io
little-proxy
dkim
alamofire
php-5.6
speech-synthesis
radgridview
docx
mvc-mini-profiler
dreamweaver
wolframalpha
sencha-touch
simpleitk
jquery-ias
inno-download-plugin
easeljs
mongoid6
monit
beta
data.stackexchange.com
custom-post-type
amazon-quicksight
firebase-analytics
cppreference
ntp
papaparse
github3.py
carriage-return
raft
magento-1.9.2.4
protein-database
sim-card
recurrent-neural-network
opensmpp
chef-solo
dbnull
xmldocument
facebook-social-plugins
optimizely
geotiff
convex-optimization
x-ray
posixct
video-conferencing
jqchart
mach-o
gameplay-kit
omxplayer
pacemaker
scaffolding
angular-ui-typeahead
libav
aspen
relativelayout
character-replacement
jdi
forwarding
ess
flock
canvg
openbabel
cryptographichashfunction
universal-image-loader
create.js
named-parameters
mintty
buffering
visual-studio-express
jammer
neos-server
insert-id
windows-98
cakephp-1.2
infobright
hibernateexception
pylucene
openfaces
contentpresenter
pnrp
netbeans6.1

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