Search This Blog

June 13, 2012

How to fix the scenario of No tests to execute via MSTEST in TFS Build 2010?

Currently I am working on TFS build 2010. I believe many of you have the same situation - the Build Controller doesn't have Visual Studio 2010 installed because it is the license issue.
In order to run some of my BVTs (2 unit tests and 1 coded web test) via mstest from TFS build, I need to install Visual Studio Test Agent 2010 to get mstest.exe first per the MSDN forum.
After kicking off a new TFS build, the interesting part is that TFS build can only execute 2 unit tests. This coded web test is never executed and the test result never appears. I can only see 2 unit tests passed in the TFS activity log (the section: Run MSTest for Metadata File).
I log in to the Build Controller and use the following command line, but this coded web test cannot be found; but 2 unit tests passed.
MSTest.exe /nologo /testmetadata:"C:\\test\qa\qatfs.vsmdi" /testlist: BVTTFS
Test XXX cannot be found.
No Tests to execute.

In my local machine, I add one basic webtest (record google.com), put all project files in the Build Controller and execute this basic webtest via the following command line:
MSTest.exe /nologo /testmetadata:"C:\\test\qa\qatfs.vsmdi" /test:webtest1
This time it shows the error.
Failed to load tests from 'c:\test\qa\qatfs\webtest1.webtest': Microsoft.VisualStudio.TestTools.TestManagement.InvalidStorageExtensionException: File extension specified '.webtest' is not a valid test extension.
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.GetTestTypeInfosForExtension(String ext)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.GetTestTypesNotManaged InStorage(String storage)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadTestsFromTipsHelper(IEnumerable`1 locations, ProjectData projectData)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadTests(IEnumerable`
1 locations, ProjectData projectData, TestConflictHandler vetoingHandler)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadTests(String location, ProjectData projectData, TestConflictHandler vetoingHandler)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadTestLinkStorageHelper.LoadTests(String fullStoragePath, ProjectData projectData)
   at Microsoft.VisualStudio.TestTools.TestManagement.Tmi.SimpleLoadTestLinkStorageHelper.Load(String fullStoragePath, ProjectData projectData)
Test webtest1 cannot be found.
Test webtest1 cannot be found.
Starting execution...
No tests to execute.
It can explain why "No tests to execute" appears in my early testing.
After some testing, the above error of Microsoft.VisualStudio.TestTools.TestManagement.Tmi.XXXXX is gone after I install Visual Studio Test Controller in the Build Controller. It means that MSTEST can't execute webtest and coded web tests nicely if you only install Visual Studio Test Agent 2010. It could also explain why the log in TFS build has the information of No Tests to execute. 

Next time if you see "No tests to execute" in TFS Build, don't worry.  Installing Visual Studio Test Controller and Visual Studio Test Agent together in your Build Controller should solve your issue. 

Besides, does it mean if you want to execute your web tests via MSTEST without Visual Studio IDE install in the Build Controller ,Visual Studio Test Controller and Visual Studio Test Agent need to be installed in the same machine? From my perspective, the answer is yes.

1 comment:

Cindy Dy said...

The simple truth is I like this article, the author's writing was very honest, very clever writing skills.

Nersha
www.gofastek.com