Forum Discussion

bgran05's avatar
bgran05
Occasional Contributor
8 years ago
Solved

Trouble running Code Snippet from other project

Hi,

 

I am trying to run a code snippet from Project A in Project B. Ultimately, I want to run Nunit Selenium tests in Project B after Project A's test has run.

 

Here is my directory structure:


+Project A

   Script Directory:

      Folder Name
          Script 1
          Script 2
      Folder Name
          Script 3
          Script 4

          Unit 1

 

+Project B

     Script Directory:

          Script
               Unit 1 - this was imported as Existing Unit 1 from Project A

     

      UnitTesting
           My Nunit Test

      KeywordTests
           KeywordTest 1

 

In Keyword Test 1, I have Run Script Routing, with the Operation: Unit 1.

 

The test instantly fails with "The USEUNIT section contains a reference to "ABC" unit that was not found in the project.

 

ABC is defined at the top of Unit 1 from Project A. Project A has many scripts (maybe a total of 20). Do I need to copy all to project B? Or is there a simpler way?

 

Thank you!

  • Everything that is in Unit1's section for "USEUNIT" needs to be in project B as well.  Anything that is a dependancy needs to be brought over.  You might not need to bring EVERYTHING over from Project B but, if there is a dependancy, it needs to be in both projects.

     

    An alternative solution is to convert commonly executed code into Script Extensions to make it easier to share code between projects.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Everything that is in Unit1's section for "USEUNIT" needs to be in project B as well.  Anything that is a dependancy needs to be brought over.  You might not need to bring EVERYTHING over from Project B but, if there is a dependancy, it needs to be in both projects.

     

    An alternative solution is to convert commonly executed code into Script Extensions to make it easier to share code between projects.