"No static 'Main' method" error when running Unit Test project

Tpiom

New member
Joined
Mar 16, 2017
Messages
3
Programming Experience
Beginner
I'm trying to setup a test framework in Sharpdevelop (open source and leightweight alt. to Visual Studio), but there's this guide where the creator is using Visual Studio.

He first creates a new project, called WordpressAutomation and a Class Library with the following code in it:
C#:
Using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
using openqa.selenium.firefox; // used to control browser

namespace WordpressAutomation
{
    public class Class1
 {
        public void Go()
    {
    var driver = new FirefoxDriver();
    driver.Navigate().GoToUrl("http://www.google.com");
    }
  }
}
He then creates another project, using the Unit test Project template in the solution and calls WordpressTests. It has the following code in it.

C#:
using system;
using microsoft.visualstudio.testtools.unittesting;
[I]using wordpressautomation;[/I]

namespace WordpressTests
{
                             [TestClass]
                             public class UnitTest1
                             {
                                                          [TestMethod]
                                                          public void TestMethod()
                                                          {
                                                                                       var c = new Class1();
                                                                                       c.Go();
                                                          }
                             }
}

He basically references the wordpressautomation code in his wordpresstest project... it opens up Firefox. Easy.

Now Sharpdevelop doesn't have a "unit test" project template so I created an empty project instead, then a Unit Test class and went from there.
However, when trying to run it gives me the "CS5001 - does not contain a static 'Main' method suitable for an entry point" error.

How can I fix this?
Thanks!
 
A Unit Test Project in VS is a class library application type, if that helps.
 
I changed output type to "Class Library" and it now tries to run, I think, but gives me another error:
"Can not start process. is not a valid Win32 application (Exception from HRESuLT 0x800700C1)
 
Depends on what you mean by "run", in VS one use a Test menu to run tests, and not "run" as regular executable project. I think it is similar in Sharpdevelop - check out web.
 
Ah, of course... Thanks for the help people!

Now it says: "OpenQA.Selenium.WebDriverException : Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed. OS appears to be: Vista" but I think it's because the driver isn't up-to-date, based on information gathered from here: https://www.ultimateqa.com/common-selenium-webdriver-errors-fix/

Also, for some reason I had to place the driver .exe in my project folder (C:\Users\XXXXX\Documents\SharpDevelop Projects\WordpressAutomation\WordpressAutomation\bin\Debug) or it wouldn't find it.

But now it runs as it should.
 

Latest posts

Back
Top Bottom