Select to view content in your preferred language

ArcGIS Pro SDK unit testing fails to open project

144
2
Jump to solution
2 weeks ago
JoePolaski
Emerging Contributor

I am trying to set up some unit tests for an add-in I am working on.  I have followed the Esri Documentation to a T and everything compiles totally fine. The problem seems to lie in ClassInitialize function provided in the guide where it calls Project.OpenAsync(@"{insert project path here}"). 

When I run my unit tests they always fail at this line and the error says that it is unable to open the project. I am certain that there is a valid project at the path I am giving it. Pro will open the project just fine if I open the project from within pro. The even stranger thing is, if I debug and manually walk through the unit tests as they are executing, the error doesn't happen and the tests pass. But only when I am using the debugger. If I run them normally they will fail every time.

Has anyone else encountered a similar issue while unit testing? I can't seem to find much on this and the things I have tried, have not worked.

0 Kudos
1 Solution

Accepted Solutions
JoePolaski
Emerging Contributor

Hi @UmaHarano ,

Thank you for responding. Yes it does, but I did end up resolving the issue. I had thought my named user license was authorized for offline work and turns out it was not (my organization had it disabled globally). So, by correcting that I was able to resolve the issue. I wasn't sure how to mark this as solved.

View solution in original post

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi @JoePolaski 

Does your unit test code for OpenAsync look similar to this? 

 

// Open existing project
      Project project = null;
      try
      {
        project = await Project.OpenAsync("project path");
      }
      catch (Exception ex)
      {
        // exception
      }
0 Kudos
JoePolaski
Emerging Contributor

Hi @UmaHarano ,

Thank you for responding. Yes it does, but I did end up resolving the issue. I had thought my named user license was authorized for offline work and turns out it was not (my organization had it disabled globally). So, by correcting that I was able to resolve the issue. I wasn't sure how to mark this as solved.

0 Kudos