Bad Bug in VS2008 - anyone know if reported or status?
I am calling MS on this since it's broke production badly:
To reproduce.
Create unit test project.
Add a file to the project called 'msEnterpriseLibrary.config'.
Add the following test in VS2005:
[
TestMethod] public void TestMethod1(){
string path = "msEnterpriseLibrary.config"; if (!Path.IsPathRooted(path)){
path =
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);}
Assert.Inconclusive();}
Add watch to AppDomain.CurrentDomain.BaseDirectory.
Notice in VS2005 it points to the actual location of you msEnterpiseLibrary.config file you added.
Now do the exact same test in VS2008. Notice here that BaseDirectory points to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
The current domain is correct in both VS2005 and VS2008, it's the implementation of the BaseDirectory that has changed and broken code.
Answers
Try adding the following ClassInitialize method to the Unit test.
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);
}
All Replies
Try adding the following ClassInitialize method to the Unit test.
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);
}
- Okay, this is good, but I have like 180 test classes; is there a way to apply this to the whole solution?
Unfortantely there is no way to add the ClassInitialize to the entire solution. It will have to be added to each Unit test class.
It's possible that this behavior may change back to original behavior as in 2005, however if this was to happen it would not be done until SP1 for Orcas 2008 and no time frame on SP1.
You can do it in AssemblyInitialize to address that once for whole test execution. I assume you have a single namespace for all 180 test classes.
I ma getting an error "Parameter 1 should be of type MicroSoft.VisualStudio.......TestContext". However, i have already written the same code as above and i included the namespace also....
The test script is not getting executed
Sagar,
if you have migrated it from VS2005 to VS2008, probably you need to update the reference of UnitTestFramework as well. for VS2008, MS has realsed new version of it. ie. 9.0.0.0. You will find it under .NET tab of "Add Rerefernce" dialog.
Component name is Microsoft.VisualStudio.QualityTools.UnitTestFramework.
Hope this helps.
-NimeX
- This didn't work for me at all. Is there something else I can do?
-David Sutherland - Pardon me. I meant to say:
[ClassInitialize]public static void ClassInitialize(TestContext testContext)
{
AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);
}
Doesn't work either.
Is there anything else I can do?
-Dave Sutherland - Does anyone know the end date for the fix from visualstudio 2008 team
Y2KPRABU, MCTS,MCPD INDIA


