Page 1 of 1

How to run TestProject through command line

Posted: Fri Nov 18, 2016 5:33 pm
by xibinki
Hi,

I read all the Ranorex information regarding on how to run a test project and individual test cases, through command line, but to be honest I'm confused.

I wish to create a .bat in which with the proper command lines to run my project with the selected tests.
I've tried to navigate to the folder where I had MyProject.exe and tried to start it from CMD by using

Code: Select all

c:\ cd Ranorex\Flow2TestProject\bin\Debug
Flow2TestProject.exe /ts
But when I try that, Windows gives me a "The current process has stopped working" and on CMD I get this message:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Flow2TestProject.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'Flow2TestProject.exe'

Can someone help me on creating a simple .bat just to run my project with all the configurations that I already saved on my project?

Thank you.

Re: How to run TestProject through command line

Posted: Fri Nov 18, 2016 6:01 pm
by krstcs
Have you tried running the project from Ranorex Studio on the same system, instead of from the command-line? My guess is that you didn't install the same version of Ranorex on the system you are trying to run the test on.

The error says that you built the project with a newer version of the .NET framework than the system you are trying to run it on has installed. You need to properly install Ranorex AND the version of .NET that is being used to build the tests on ALL systems that are going to be used to create, build, or run the Ranorex tests. The easiest way to do this is to run the Ranorex installer EXE (download here: Ranorex-6.1.1.exe). This will install Ranorex and all the prerequisite .NET and C libraries required to run the tests correctly.

Re: How to run TestProject through command line

Posted: Fri Nov 18, 2016 6:51 pm
by xibinki
I downloaded and installed that version and still get the same error when I try to run MyProject.exe (the .exe crashes and gives the same message).


Also, I converted the project to the latest .Net Framework 4.5.2 and when I try to install that same framework, it says that my computer already has the latest version of it.


One thing I didn't mentioned, is that have my project on a different directory from the Ranorex installation, because I had to create a repository with TortoiseHg in order to guarantee that I backup the project.

I'm running out of ideas...

All I have to do is navigate to the directory of my project on CMD and then type:

Code: Select all

Myproject.exe /ts

Right?

Re: How to run TestProject through command line

Posted: Fri Nov 18, 2016 7:27 pm
by krstcs
First, this still sounds like an issue with the install not being the same as the system you built the test on originally. Did you rebuild the project on the problem system after installing?

Second, Ranorex command-line switches can be seen here: http://www.ranorex.com/support/user-gui ... html#c4827

You will notice that the "/ts" switch REQUIRES A DIRECTORY/FILENAME of the suite file (*.rxtst) that you want to run. However, if that suite file has the same name and is located in the same directory as your EXE, then you don't need to provide that switch.

You need to copy ALL of the files in your <Project>\bin\debug\ folder over to the new location.

You should be able to just run the associated test and suite by using the command-line:

Code: Select all

Myproject.exe
Or, you can run a different, or non-co-located suite (that must have been built with the same project!!) by using:

Code: Select all

Myproject.exe /ts:<Location of the suite>\<Name of the suite>.rxtst

EDIT TO ADD: It is HIGHLY RECOMMENDED by Ranorex that you ONLY have ONE test suite per project in your solutions. Multiple suites may cause unexpected side-effects and are NOT SUPPORTED!

Re: How to run TestProject through command line

Posted: Fri Nov 18, 2016 8:33 pm
by xibinki
I'm confused about your statement:
First, this still sounds like an issue with the install not being the same as the system you built the test on originally. Did you rebuild the project on the problem system after installing?
Because I initially started the project on a computer with Windows 8 and Ranorex 6.0. Then I migrated the project to a different computer with Windows 10 and Ranorex 6.1. So basically, different computers with different O.S.
I copied the Ranorex Project folder located on the C:\Users\Documents\RanorexProject to a different location (D:\repository\RanorexProject\) and did "Clean Solution" and then "Rebuild". Everything is working, the case tests work perfectly fine... I even developed new case tests on this new computer with Windows 10.

I'm getting the feeling that your telling me that there's something wrong with my entire project just because I switched computers and operating systems. If this is the case, what should I do to my current project, in order to clear all the eventual tracers of the old computer and in order to have a "clean" solution on the current computer?

Re: How to run TestProject through command line

Posted: Fri Nov 18, 2016 9:44 pm
by krstcs
OK, maybe I'm confused, but I understood from your first post that you were attempting to run the test on a different system than the one you compiled it on. That is why I said what I did. You shouldn't have any problems with upgrading from Ranorex 6.0 to 6.1.1 (the currently supported version).

So, let's step back and make sure we are both on the same page... :D


Can you answer the following:
1. Have you compiled and run the tests in Ranorex Studio on your current development system using Ranorex 6.1.1 and Windows 10? Did they work correctly? (You seem to indicate that they did.)

2. Is the system that you are having the problem on the same one as above, or is it different? If the system is DIFFERENT, what version of Ranorex and .NET are installed, and what OS is being used?

3. Are you trying to run or build the test from a network share (i.e. is the D: drive you reference a network share)? If so, this is not supported and you MUST have all files on the LOCAL file system. If your D: drive is a local drive, then this should not be a problem.


EDIT TO ADD: In addition, you really should be using a Version Control System such as SVN, Git, or TFS to version control and manage your source files. This will keep you from losing valuable work and time if you happen to have a disk crash, or if you make a mistake and need to roll back to a previous version of your code. You are creating software, so you need to treat your project like any other software project.

Re: How to run TestProject through command line

Posted: Sun Nov 20, 2016 10:59 pm
by xibinki
So to answer your post:

1. Yes, I ran my test project under Ranorex 6.1.1 on Windows 10 and everything went smoothly.

2. The system is the same. I run the test project on the computer "Testing Machine" with Ranorex and I wish to run the same project on the same computer through CMD.

3. The D:\ drive is a HDD installed on the computer "Testing Machine", the same computer where I run the project with Ranorex and wish to run the same project through CMD.


I use a "Version Control System", TortoiseHG. I have the repository of the entire project on a different machine, the main server on my company.

EDIT1:
So, I have new developments!!! I managed to make MyProject.exe to work!!! I went to Properties of my project under Ranorex and changed the Debug .Net Framework compilation to 4.0 (cause I've changed it to 4.5.2 thinking that this would give more compatibility or something, but now I changed it back to 4.0).
Now what I need to do, is to be able to call "MyProject.exe" through a .bat, cause the idea here is to work on my laptop and click on this .bat so it starts the test run of my project on the main server.

Basically I need to call in the .bat my "MyProject.exe" through the network, something like:

Code: Select all

\\Testing Machine\Desktop\Debug\MyProject.exe
Does this work? lol :x

EDIT2:
Ok, so I managed to put things to work. Now I have to create this .bat to run things remotely, already installed PSexec but this is not a Ranorex issue from now on :x have to search a little bit more about this subject.