Bug 13131 - Cannot reference exe projects while Unit testing
Summary: Cannot reference exe projects while Unit testing
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 7.0.6.x
Hardware: PC Mac OS
: Lowest enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
: 12885 ()
Depends on:
Reported: 2013-07-09 12:49 UTC by Gleb
Modified: 2014-01-31 12:30 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Gleb 2013-07-09 12:49:17 UTC

I tried to write unit tests for my iOS app using this tutorial http://docs.xamarin.com/guides/ios/deployment,_testing,_and_metrics/touch.unit
But I can't add a reference from test project to devel project since it says "Cannot reference exe projects"

How to reproduce:

1. Create new iOS project (Master)
2. Create new iOS tests project (test)
3. Test project-> References->Edit References
4. Select "Project" in opened window.
Result: You can't select Master project due to "Cannot reference exe projects"
Expected: You can refer the Master project

It is kind a bug/or/feature issue but reference to the working project is pretty common way. I don't want to create dll every time I want to run tests.
Comment 1 Sebastien Pouliot 2013-07-09 13:42:54 UTC
That's an IDE restriction -> Xamarin Studio

OTOH, without the restriction, you'll likely hit another issue. The (unit test) application will try to register "AppDelegate" multiple time with the ObjC runtime. That will fail in some scenarios (e.g. the static registrar won't allow this when running on devices).

If you really want to avoid a .dll then you can reference the exe source files inside your unit test project.
Comment 2 Jeffrey Stedfast 2013-07-15 12:09:40 UTC
exe projects are meant to produce native executables, not nunit testable assemblies.
Comment 3 Jeffrey Stedfast 2013-10-30 14:35:43 UTC
*** Bug 12885 has been marked as a duplicate of this bug. ***
Comment 6 Jeffrey Stedfast 2014-01-30 13:08:19 UTC
 -> Xamarin.iOS issue
Comment 7 Jeffrey Stedfast 2014-01-31 12:24:34 UTC
Probably should have explained why I reassigned.

The sample unit test project builds fine in XS and deploys to device, but all of the tests (seems to be only 1 test, actually) fail.

No idea why.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2014-01-31 12:30:33 UTC
That test is failing because it can't find an image.

That image's Build Action is BundleResource - which means it will be copied to the .app directory of its project (the main project).

The unit test project only references AppProject.exe, and the image file isn't connected at all to the .exe, so the image will not be copied to the unit test .app directory.

You'll have to manually include the image (with the corresponding directory) in the unit test project for this to work.