Visual studio data driven unit test case - limit iteration
-
Sunday, March 04, 2012 8:50 AMI have 1000 rows in a table in database. I need to use this table as a data source to my unit test case but don't want to run the test case for all 1000 rows.
Is there any way I can limit the number of iterations for unit test case so that the test run only for say 10 records and not for all 1000 records. I do not want to create views in Database to support this.- Edited by Moss_Sharepoint Sunday, March 04, 2012 9:44 AM
All Replies
-
Tuesday, March 06, 2012 7:17 AMModerator
Hi Moss,
Thank you for posting in the MSDN forum.
The simple way: We can create a new data source for the 10 rows.
Another way: we can used the ADO.Net knowledge, for example, we can use it like this “SELECT top 1o from table…”, we can store the data in a new data source, then use this new data source in the unit test.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Proposed As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Friday, March 09, 2012 1:37 AM
- Marked As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Monday, March 12, 2012 8:23 AM
-
Tuesday, March 06, 2012 8:09 PMThanks for your response John. I can do the query by myself but as I stated wanted to check if we can set the limit to DataSource attribute itself?
-
Wednesday, March 07, 2012 4:54 AMModerator
Hi Moss,
Glad to receive your reply.
In the Web test, we can use the Plug-in to select the rows in the data source directly, but in the unit test, based on my understanding, it doesn’t support it. So I suggest you could use the ways provided by me in the first reply. Thanks for your understanding.
Have a nice day,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Edited by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Wednesday, March 07, 2012 4:54 AM
-
Friday, March 09, 2012 12:46 AM
Thanks for the confirmation that it is not supported with Unit tests. I actually thought of extending the DataSource class but unfortunately that is also sealed :(
-
Friday, March 09, 2012 1:37 AMModerator
Hi Moss,
Maybe the next version can achieve it. You could submit the suggestions and ideas: http://visualstudio.uservoice.com/forums/121579-visual-studio. Microsoft engineers will evaluate them seriously, thanks for your understanding.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us

