I have an issue here, as soon as I hit compile , mstest cmd prompt shows up then it crashes/goes away and my test won't get executed. This is the code :
public void test(String testContainer, String testName)
{
// String Path = @"C:\Program Files\Microsoft Visual Studio 10.0 Common7\IDE\mstest.exe";
String Path = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe";
// String Path = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""";
Process myProcess = new Process();
// ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, "/testsettings:local.testsettings /testcontainer:" + testContainer + " /test:" + testName);
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, "MSTest/testcontainer:" + testContainer + " /test:" + testName + @"/testcategory:""ActionCol""");
myProcessStartInfo.UseShellExecute = false;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
// MessageBox.Show(x + "\n" + y);
}
And this is how I call this method :
private void button3_Click(object sender, EventArgs e)
{
x = @"C:\Users\butoiu.edward\Desktop\Lucru\SimarpiUnitTest\GestcollTestSolution\CodedUITestProject\bin\Debug\GestcollTestProject.dll";
y = "ActionCollInsert";
test(x, y);
}
What am I doing wrong ? Really need some help here, thanks in advance
EDIT 1 - this is how a testmethod looks like in my other project., forgot to mention I have 2 projects under the same solution ( doesn't change a thing, but I think it's worth mentioning)
[TestMethod(), TestCategory("ActionCol")]
public void ActionCollInsert()
{
MessageBox.Show("test");
//using the proper map
var actionColTest = new ActionColMap();
//actionColTest.ActionColOpen1();
// actionColTest.ActionColSlider();
actionColTest.ActionColHideCollumns();
actionColTest.ActionColInsert();
actionColTest.ActionColInsertCode();
actionColTest.ActionColInsertDesc();
actionColTest.ActionColSave();
}
EDIT2 - How I start DEV-CMD - using shell to start my cmd from it's shortcut's position fixed up things for me.As I fixed this issue, a new one appeared. I can't pass arguments into the cmd, I mean nothing happens.
public void test(String testContainer, String testName)
{
// String Path = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe";
String Path = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Visual Studio 2012\Visual Studio Tools\Developer Command Prompt for VS2012.lnk";
Process myProcess = new Process();
// ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, "/testsettings:local.testsettings /testcontainer:" + testContainer + " /test:" + testName);
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path, "MSTest/testcontainer:" + testContainer + " /test:" + testName );
myProcessStartInfo.UseShellExecute = true;
myProcessStartInfo.Arguments = "blah blah"; // - this ain't working !!!!
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
}
EDIT3 - I am able to start a cmd and pass some arguments to it ( source : Passing an argument to cmd.exe). But changing the path to my dev cmd prompt will not insert automatically the parameter. Need some help, /c has no effect on dev cmd.
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = Path;
proc.Arguments = @"/c ping 10.2.2.125";
proc.UseShellExecute = true;
Process.Start(proc);