2

I have a suite of Webdriver tests which are written with C# and I am using MSTest as a runner. At this point NUnit is not an option, so I need to figure this out how to make it work with the current configuration. For CI I am using Jenkins ver. 1.514. I am not in control of what plugins are being installed or when Jenkins is updated and if asking such a thing might lead to a long wait and approval processes in different teams (hate birocracy).

So.. I have a few DataDriven tests which are defined as follows(i'll paste in one of them)

  [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "UsersData.csv", "UsersData#csv", DataAccessMethod.Sequential)]
    [TestMethod()]
    public void Test_Login()
    {
        Logger.Info("");
        Logger.Info("-----------------------------------------------------------------");

So, this should be clear enough that i am using UsersData.csv file, which is placed in TestData folder in my project. To run this test in Jenkins, I used to use this command line

mstest /testmetadata:"%WORKSPACE%\SeleniumJenkins.vsmdi" /testlist:Jenkins /resultsfile:"%WORKSPACE%\AllTests_Jenkins.trx" /runconfig:"%WORKSPACE%\Local.testsettings" /detail:stdout

Everything worked just fine, but one day, when i encountered this error in the TRX results file:

The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.Error details: The .Net Framework Data Providers require Microsoft Data Access Components(MDAC).  Please install Microsoft Data Access Components(MDAC) version 2.6 or later.Retrieving the COM class factory for component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due to the following error: 8007007e The specified module could not be found. (Exception from HRESULT: 0x8007007E).

BUT if i log on the machine where the slave is running and run the same command it seems it finds the DataSource files and ir runs ok.

Moreover, i installed psexec and i placed the command into a *.bat file, then i called this file from ps exec like this:

psexec \\my_IP -u "machine-name\jenkins-local" -p "password" cmd /C call "%WORKSPACE%\Selenium\msteststart.bat" 

This seems to be working, but i don't get any Logging into Jenkins and if i redirect it to a file, then whenever another build starts and wipes out the workspace the file is lost, so i only have the last version of the file and i cannot compare it to other builds.

The local.testsettings file looks like this:

<?xml version="1.0" encoding="UTF-8"? >
    <TestSettings name="Local" id="06505635-693a-4f31-b962-ecf8422b5eca" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
       <Description>These are default test settings for a local test run.</Description>
       <Deployment>
          <DeploymentItem filename="Selenium\TestData\UsersData.csv" />
       </Deployment>
   <NamingScheme baseName="Selenium_" useDefault="false"  />
   <Execution>
     <Timeouts testTimeout="10800000" />
       <TestTypeSpecific>
         <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
           <AssemblyResolution>
            <TestDirectory useLoadContext="true" />
           </AssemblyResolution>
        </UnitTestRunConfig>
      </TestTypeSpecific>
    <AgentRule name="Execution Agents">
    </AgentRule>
   </Execution>
</TestSettings>

I would appreciate if anyone could give me a hint on this one. Thanks

vali83
  • 157
  • 1
  • 4
  • 13

1 Answers1

0

It could be

  • an MDAC installation error. E.g. here are some ideas on how to repair it. Consider asking your admin to try to check if MDAC was properly installed.
  • a permission issue ? are you 100% sure you are running the command on your slave as the same user both using jenkins slave and psexec ?

As you say you manage to get it to work using psexec, a workaround would be to generate the file on the same machine the job is ran and archive the generated log file as artifact. Jenkins will keep track of it.

If you prefer to try to have the output in the console, maybe to apply console parsing, you can also make it that your psexec command outputs the file after the build to the console (by type-ing it after it has run), or maybe use this tee-like batch command to manage to get psexec to output what it does into jenkins console: Using a custom Tee command for .bat file

And don't forget to capture the standard error as well!

Community
  • 1
  • 1
coffeebreaks
  • 3,787
  • 1
  • 26
  • 25