English 中文(简体)
Integration test failing through NUnit Gui/Console, but passes through TestDriven in IDE
原标题:

I am using NHibernate against an Oracle database with the NHibernate.Driver.OracleDataClientDriver driver class. I have an integration test that pulls back expected data properly when executed through the IDE using TestDriven.net. However, when I run the unit test through the NUnit GUI or Console, NHibernate throws an exception saying it cannot find the Oracle.DataAccess assembly. Obviously, this prevents me from running my integration tests as part of my CI process.

NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly Oracle.DataAccess could not be found. Ensure that the assembly Oracle.DataAccess is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.*

I have tried making the assembly available in two ways, by copying it into the bindebug folder and by adding the element in the config file. Again, both methods work when executing through TestDriven in the IDE. Neither work when executing through NUnit GUI/Console.

The NUnit Gui log displays the following message.

21:42:26,377 ERROR [TestRunnerThread] ReflectHelper [(null)]- Could not load type Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess. System.BadImageFormatException: Could not load file or assembly Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342 or one of its dependencies. An attempt was made to load a program with an incorrect format.

File name: Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342 ---> System.BadImageFormatException: Could not load file or assembly Oracle.DataAccess or one of its dependencies. An attempt was made to load a program with an incorrect format.

File name: Oracle.DataAccess

I am running NUnit 2.4.8, TestDriven.net 2.24 and VS2008sp1 on Windows 7 64bit. Oracle Data Provider v2.111.7.20, NHibernate v2.1.0.4.

Has anyone run into this issue, better yet, fixed it?


Sly, Thanks for the reply. However, the NUnit test runner was using the correct configuration file as I was testing by pulling a known value out of the expected configuration file.

I am assuming this has something to do with my configuration, specifically with either Windows 7 in general or the 64bit version. I went ahead and installed/configured the Oracle client on the build server (W2k3 Server). I moved the test onto the build server and ran the same scenarios described above and the tests worked as expected in all cases.

I followed this up by running through the scenarios on two of the other developer workstations (Win XP 32bit with same toolset versions) and the tests worked as expected in all cases.

I m perplexed but satisfied for now. I can run my integration tests through the IDE and can execute them on the build server through our CI automation. Only problem now is I can t test the automation build project on my development workstation.

问题回答

I was getting this error when I tried to run an application which used Oracle.DataAccess.dll (odp.net version 2.111.7.20). I was shipping the oracle 11g instant client alongside the application. On 64 bit servers it would fail. However, the client assemblies I was shipping were 32 bit so I compiled a version of the app with the CPU flag set 32-bit and now it works fine. This is because the server runs the entire component within the wow64 emulator when you tell it the app is 32bit explicitly.

I had a similar problem when configuring NHibernate. The thing is that most of test runners are using app.config that is placed with your tests dll. But some versions of NUnit don t. Thats why your system stays in not configured state for the tests. You can try to configure NHibernate mannually from the test. Hope it helps

I may have just solved a similar/same problem on my local machine by going into the build settings for the test project and changing platform target from "any cpu" to "x86"





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签