- Overview
- Guides
- Concepts
- Considerations And Constraints
- Absolute File References
- Assembly Colocation Assumptions
- Concurrent Use Of Test Resources
- Cross Application Domain Testing
- Heavily Executed Code Under Test
- Implicit File Dependencies
- Multi Threaded Tests
- Netstandard Test Projects
- Project Atomicity
- Project Build Platform And Configuration
- Rdi Data Point Location
- Test Atomicity
- Unique Test Names
- Using NCrunch With Source Control
- Reference
- Global Configuration
- Overview
- Auto Adjust Clashing Marker Colours
- Build Log Verbosity
- Build Process Memory Limit
- Capabilities Of This Computer
- Coverage Marker Style
- Cpu Cores Assigned To NCrunch Or Ide
- Custom Environment Variables
- Disable Global Hotkey
- Engine Hosting Strategy
- Fast Lane Threads
- Fast Lane Threshold
- Grid Maximum Reconnection Attempts
- Grid Reconnection Delay
- Impact Detection Mode
- Listening Port
- Log To Output Window
- Logging Verbosity
- Marker Colours
- Max Failing Test Trace Log Size
- Max Number Of Processing Threads
- Max Passing Test Trace Log Size
- Max Test Runners To Pool
- NCrunch Tool Window Colors
- Node Id (Name)
- Password
- Performance Aggregation Type
- Performance Display Sensitivity
- Pipeline Optimisation Priority
- Rdi Storage Settings
- Sliding Build Delay
- Snapshot Storage Directory
- Solution Storage Data Limit
- Spinner Colours
- Terminate Test Runners On Complete
- Test Process Memory Limit
- Tests To Execute On This Machine
- Text Output Font
- Workspace Base Path
- Solution Configuration
- Overview
- Additional Files For Grid Processing
- Additional Files To Include
- Allow Parallel Test Execution
- Allow Tests In Parallel With Themselves
- Infer Project References Using Assembly
- Instrumentation Mode
- NCrunch Cache Storage Path
- Only Consider Tests Outofdate If Impacted
- Project Config File Storage Path
- Show Coverage For Tests
- Show Metrics For Tests
- Tests To Execute Automatically
- Project Configuration
- Overview
- Additional Files To Include
- Allow Dynamic Code Contract Checks
- Allow Static Code Contract Checks
- Analyse Line Execution Times
- Autodetect Nuget Build Dependencies
- Build Priority
- Build Process Cpu Architecture
- Build Sdk
- Collect Control Flow During Execution
- Consider Inconclusive Tests As Passing
- Copied Project Dependencies
- Copy Referenced Assemblies To Workspace
- Custom Build Properties
- Data Storage File Size
- Default Test Timeout
- Detect Stack Overflow
- Enable Rdi
- Files Excluded From Auto Build
- Framework Utilisation Types
- Ignore This Component Completely
- Implicit Project Dependencies
- Include Static References In Workspace
- Instrument Output Assembly
- Method Data Limit
- Ms Test Thread Apartment State
- Preload Assembly References
- Prevent Signing Of Assembly
- Proxy Process File Path
- Rdi Cache Size
- Required Capabilities
- Restrict Tostring Usage
- Run Pre Or Post Build Events
- String Length Limit
- Track File Dependencies
- Use Build Configuration
- Use Build Platform
- Use Cpu Architecture
- Runtime Framework
- Overview
- Atomic Attribute
- Category Attribute
- Collect Control Flow Attribute
- Distribute By Capabilities
- Duplicate By Dimensions
- Enable Rdi Attribute
- Environment Class
- Exclusively Uses Attribute
- Inclusively Uses Attribute
- Isolated Attribute
- Method Data Limit Attribute
- Requires Capability Attribute
- Restrict Tostring Attribute
- Serial Attribute
- String Length Limit Attribute
- Timeout Attribute
- Uses Threads Attribute
- Global Configuration
- Troubleshooting
- Tools
- Keyboard Shortcuts
- Manual Installation Instructions
Project Atomicity
Description
When NCrunch prepares to build a project, it will first identify and copy all files relevant to the project into an isolated workspace for processing. The building of this workspace involves the complete extraction of a cloned project from its parent solution. There are many mechanisms in NCrunch designed to make this extraction as seamless as possible, although this design does have implications and imposes constraints on the structure of the projects being extracted.
Possible Problems
The extraction of a project from its parent solution requires the reliable identification of all files needed for the project to be built and tested in isolation. NCrunch works very hard to identify these files although there is the possibility that some may be referenced implicitly, causing build and test run-time issues.
To make use of separated projects in their workspaces, NCrunch uses its knowledge of the relationships between projects to artificially wire them together at build and test run-time. This means that if NCrunch is unaware of a dependency between projects, it is very possible that tests or builds may fail to run correctly.
An example of a possible failure scenario is a test that launches a webserver pointing at a website path relative to the test project assembly. This kind of reference is beyond just an implicit set of file references, as it also relies on the web project to first be built before the webserver is launched.
Solutions
Design Projects For Clean Separation
Although this may not be feasible for projects that have been developed for years without NCrunch, designing projects with separability in mind can save huge amounts of trouble when using NCrunch. Try to ensure projects clearly state their references to each other using <ProjectReference> tags in their .proj files. Avoid creating complex build situations that involve cross-references and reliance on implicit behaviour or solution structure. Avoid developing projects that introduce side-effects as part of their build process, or suppress custom build steps that do this by using conditional build behaviour.
Use NCrunch Reference Data To Find Referenced Assemblies
In the example cited above (a test launching a webserver), it is possible to make the test behave normally by using NCrunch's assembly reference data to find the location of the website root path. An example of this can be found in tests that build their own appdomains. The implicit project dependencies setting can also be useful in this situation if the web project itself is not explicitly referenced from the test project.
Use 'Additional Files To Include'
A very crude but simple solution is to treat all files and implicitly referenced projects used by a test project as extensions of the test project itself. You can use the Additional files to include configuration setting to include the files in the test project's workspace. In the webserver example cited above, this approach would mean that the website itself must be built manually using your IDE before the test code could work with the correct version of the website's assemblies.