Build/Test Issues

How to get files referenced by cs included by ncrunch?

Started by Stant on 3,777 views

We are hitting the classic issue: Files needed in the test env are not included in the build output. Full error below.

But we do not know how to approach this!

Flow:
cs code reference files on disk (excel xls files). These files are imported into a sqllite file, and then the cs code runs against sqllite

When we run in vs under nunit or testdriven.net, the tests run and pass.

But in ncrunch, we get the error below.

ncrunch is right (because the files are not in the project reference). But they need to both be included AND in the right location for it all to work.

Questions:
Sooooo, we need to understand how to add references to the xls files so that:

a) Code will still run and test and find the xls files when run locally (files will be off in some path from version control, not in dir next to cs)

b) xls is included so ncrunch can see them

c) What compiler directives do we use so that when ncrunch compiles, the cs will look in different location?

d) How can we see/understand the ncrunch run time env? We need to know so we can make appro adjustments in code (prob under compiler directives that only fire when running under ncrunch)

Thanks!


System.ApplicationException : Unable to import data from '..\..\..\sourcedata\2016\BaseData48States.xls', sheet: main-excel_Z . Directory "..\..\..\sourcedata\2016" does not exixt.
at testapplication.Rating.LoaderBaseRatesFromExcelData.LoadRateCharts(CensusBaseRateDatabase baseRateDatabase, String ratesFilename, String xlsSheet, TCensusService service, List`1 zoneNames) in C:\Develop\testapplication\Current\WebApplications\testapplicationWeb\testapplication.Rating\testapplication.Rating.Core\Census\DataLoader\LoaderBaseRatesFromExcelData.cs:line 230
at testapplication.Rating.LoaderBaseRatesFromExcelData.Loadmain-excel_Z(CensusBaseRateDatabase baseRateDatabase, String path) in C:\Develop\testapplication\Current\WebApplications\testapplicationWeb\testapplication.Rating\testapplication.Rating.Core\Census\DataLoader\LoaderBaseRatesFromExcelData.cs:line 46
at testapplication.Rating.LoaderBaseDataAbstract.LoadRatesAll(String path, String ratesDatabaseFileName) in C:\Develop\testapplication\Current\WebApplications\testapplicationWeb\testapplication.Rating\testapplication.Rating.Core\Census\DataLoader\LoaderBaseDataAbstract.cs:line 99
at testapplication.Rating.A_RunFirst.LoadingCensusDataTests_2016.A_LoadBaseRates() in C:\Develop\testapplication\Current\WebApplications\testapplicationWeb\testapplication.Rating\testapplication.Rating.Tests.RunOnBuildBox\Census\LoadingCensusDataTests_2016.cs:line 98
Hi,

If I understand this problem correctly, it should be possible for us to fix this fairly easily.

NCrunch builds shadow copies of your projects when it builds them, called 'workspaces'. These workspaces can be viewed by right-clicking a project in the Tests Window and choosing Advanced->Browse To Workspace.

For NCrunch to copy files into the workspace, it needs to be aware that these files are required for the project. Most files are auto-detected, but some need to be specified using configuration. See implicit file dependencies for more details.

There are ways to introduce conditional behaviour in your code dependent on NCrunch, but I don't think this is necessary to solve your problem and should ideally be avoided where possible.

Post a reply

Log in to reply.