chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I have a test that passes 100% time in Visual Studio 2005. When I attempt to run it through the command line using NCover, it fails 100% of the time.

I have tried all the following calling syntaxes:
TMockRunner -first -link NCover ncover.console.exe nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml

ncover.console.exe nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml //a MaestroModel_UT

nunit-console.exe Maestro.nunit /noshadow /xml:c:cc ests.xml

I have tried it with and without NCover linked to TypeMock through the configuration utility.

The Test:

public void canCreate4DataTablesWhenConfigAsksForThem() {
MaestroModel model = new MaestroModel();
DataStructureCreator creator = new DataStructureCreator();
DataTable stationTable = creator.getChildDataTableWithASingleStation();
GridConfigurationData configurationData = getGridConfigurationData();
using(RecordExpectations recorder = RecorderManager.StartRecording()) {
MaestroDataReaderFactory dataReaderFactory = new MaestroDataReaderFactory();
IMaestroDataReader dataReader = dataReaderFactory.createMaestroDataReader(MaestroDataReaderFactory.DataReaderTypes.DirectSqlDataReader);
recorder.Return(new DirectSqlDataReader());
DataTable readings = dataReader.GetAllCurrentReadingsByStationID(1);
List <DataTable> tables = model.getSiteStatusTables(1, 99, "Middle Earth", configurationData);
Assert.AreEqual(7, tables.Count);

The Result:

1) QTT.Maestro.Model.Test.MaestroModel_UT.canCreate4DataTablesWhenConfigAsksForThem : System.NullReferenceException : Object reference not set to an instance of an object.
at System.Data.SqlClient.SqlConnection.SetInnerConnectionEvent(DbConnectionInternal to)
at System.Data.SqlClient.SqlConnectionFactory.SetInnerConnectionEvent(DbConnection owningObject, DbConnectionInternal to)
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlInternalConnection.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Close()
at QTT.Maestro.Model.DataAccess.DirectSqlDataReader.getDataTable(SqlConnection connection, SqlCommand command, String tableName) in C:MaestroTrunkProjectsMaestroModelDataAccessDirectSqlDataReader.cs:line 35
at QTT.Maestro.Model.DataAccess.DirectSqlDataReader.GetAllCurrentReadingsByStationID(Int32 stationID) in C:MaestroTrunkProjectsMaestroModelDataAccessDirectSqlDataReader.cs:line 24
at QTT.Maestro.Model.MaestroModel.getSiteStatusTables(Int32 stationGroupID, Int32 stationID, String stationGroupName, GridConfigurationData gridConfigurationData) in C:MaestroTrunkProjectsMaestroModelMaestroModel.cs:line 57
at QTT.Maestro.Model.Test.MaestroModel_UT.canCreate4DataTablesWhenConfigAsksForThem() in C:MaestroTrunkProjectsTe
stsMaestroModel_UTMaestroModel_UT.cs:line 34

I am using :
TypeMock Enterprise
NUnit 2.4.1
Visual Studio 2005
Framework 2.x
OS Microsoft Server 2003

Sure could use some help on this one.
asked by remcam (600 points)

1 Answer

0 votes

From your post I wasnt able to figure out if its an NCover related issue, or just problem running from command line.

Try to see if you can run the tests from command line without NCover involved (use TMockRunner nunit-console.....)

Also at the start of the test you perform several things that looks like may access external resourcs i.e. files, datbase,... is it possible that they are affected when you run from command line?
answered by lior (13.2k points)