New Posts New Posts RSS Feed: *.config not found when running Unit Test
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

*.config not found when running Unit Test

 Post Reply Post Reply
Author
Pooky View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2008
Location: Switzerland
Posts: 2
Post Options Post Options   Quote Pooky Quote  Post ReplyReply Direct Link To This Post Topic: *.config not found when running Unit Test
    Posted: 04-Mar-2008 at 4:47am
Hello there,
I spotted a similar problem when using the Persistence Manager in a UserControl during Designtime in another thread. But it seems this problem also occurs when creating Unit Tests with VSTS2008. I have a blank Form and some generated entities in a Model. I tried to write a first Test (I'm working through the Developers Guide). When I try to run the Test, it fails with a IdeaBlade.Util.IdeaBladeException:

Test method Model.Test.tbl_OETest.FullNameTest threw exception:  IdeaBlade.Util.IdeaBladeException: Unable to obtain a valid configuration file on P1058.

Probing path:
1) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.config - not found
2) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe.config - not found
3) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\vsdiag_regwcf.exe.config - not found
4) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\VSTestHost.exe.config - not found
5) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\VSTST-FileConverter.exe.config - not found
6) File: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\IdeaBlade.ibconfig - not found
7) Design-time execution detected - Will not probe for app.config or IdeaBlade.ibconfig in AppHelper
8) IdeaBlade.ibconfig fallthru - Default IdeaBlade.ibconfig used
9) Logging file:

Stack Trace:
IdeaBlade.Util.IdeaBladeConfig.AssertNonDefaultVersion()
IdeaBlade.Persistence.PersistenceManager..ctor(Boolean pShouldConnect, String pDataSourceExtension, PersistenceServiceOption pPersistenceServiceOption)
IdeaBlade.Persistence.PersistenceManager.get_DefaultManager()
Model.Test.tbl_OETest.FullNameTest() in C:\src\VB.NET\Visual Studio 2008\UserDB_ORM\Model.Test\tbl_OETest.vb: line 69

-->
    <TestMethod()> _
    Public Sub FullNameTest()
        Dim pm As PersistenceManager = PersistenceManager.DefaultManager
Here it fails when I run the Test

-->
If I call the Test Method in the Form Load Method it works(!)
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim testobj As New Model.Test.tbl_OETest
        testobj.FullNameTest()
    End Sub

I can not understand what a Test Class has to do with Designtime, and even if it would, I fail to find a DesignMode Property there to work around this. And even IF it is a Designtime problem, then why does it work in my Form_Load Event? :-)


Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 04-Mar-2008 at 10:38am
We ran into the very same issue when we started running our own Unit Tests on our V4 product (which runs only under VS2008).

Here’s the code we’re using – you’ll find an Initialize() method in all our V4 Unit Tests.

 

    [TestInitialize]

    public void Initialize() {

      // With the VS2008 Test framework the AppDomain and base directory will be pointing

      // to the common/ide directory and config file probing will fail if you're using the AppHelper. 

      // Here’s a workaround:

      IdeaBladeConfig.ConfigFileAssembly = System.Reflection.Assembly.Load("AppHelper");

    }

 

Note that the initialization isn’t strictly required in [TestInitialize], that’s just what we use.

 

 

Back to Top
Pooky View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Mar-2008
Location: Switzerland
Posts: 2
Post Options Post Options   Quote Pooky Quote  Post ReplyReply Direct Link To This Post Posted: 05-Mar-2008 at 12:36am
Thanks David, you saved my day.


Back to Top
RJayTaylor View Drop Down
Newbie
Newbie
Avatar

Joined: 27-Jun-2007
Location: Canada
Posts: 3
Post Options Post Options   Quote RJayTaylor Quote  Post ReplyReply Direct Link To This Post Posted: 05-Mar-2008 at 11:26am
Yes thanks.  I was getting nowhere and couldn't figure out why.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down