Error:Cannot find “Static Main” in Unit test of Winforms





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have created the Slave Simulator Application using Winforms and had to add the Unit Test Project to it.



I have added the Unit Test Project and also added the proper reference of my application.But when I run the test case, I am getting the error as " Program Does not Contain Static Main method suitable for entry point".I have changed Output type to "Windows Application" and there is a Program.cs(which includes main method) in my Application.



following is my Unit test project code I have written



public class UnitTest1
{
[TestMethod]
public void TestCoilUpdateOperation()
{
UpdateCoilsToDataStore testObject = new UpdateCoilsToDataStore();
bool actualStatus = testObject.UpdateCoils(UpdateCoilsToDataStore.TagName, UpdateCoilsToDataStore.ParameterNames, UpdateCoilsToDataStore.FunctionCode);
bool expectedStatus = true;
Assert.AreEqual(expectedStatus, actualStatus);
}
}


Can you please help me to resolve this problem.
Thanks.










share|improve this question


















  • 1





    A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

    – Amy
    Nov 22 '18 at 6:00











  • "I have changed Output type to "Windows Application" - big mistake

    – T.S.
    Nov 22 '18 at 6:31


















0















I have created the Slave Simulator Application using Winforms and had to add the Unit Test Project to it.



I have added the Unit Test Project and also added the proper reference of my application.But when I run the test case, I am getting the error as " Program Does not Contain Static Main method suitable for entry point".I have changed Output type to "Windows Application" and there is a Program.cs(which includes main method) in my Application.



following is my Unit test project code I have written



public class UnitTest1
{
[TestMethod]
public void TestCoilUpdateOperation()
{
UpdateCoilsToDataStore testObject = new UpdateCoilsToDataStore();
bool actualStatus = testObject.UpdateCoils(UpdateCoilsToDataStore.TagName, UpdateCoilsToDataStore.ParameterNames, UpdateCoilsToDataStore.FunctionCode);
bool expectedStatus = true;
Assert.AreEqual(expectedStatus, actualStatus);
}
}


Can you please help me to resolve this problem.
Thanks.










share|improve this question


















  • 1





    A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

    – Amy
    Nov 22 '18 at 6:00











  • "I have changed Output type to "Windows Application" - big mistake

    – T.S.
    Nov 22 '18 at 6:31














0












0








0








I have created the Slave Simulator Application using Winforms and had to add the Unit Test Project to it.



I have added the Unit Test Project and also added the proper reference of my application.But when I run the test case, I am getting the error as " Program Does not Contain Static Main method suitable for entry point".I have changed Output type to "Windows Application" and there is a Program.cs(which includes main method) in my Application.



following is my Unit test project code I have written



public class UnitTest1
{
[TestMethod]
public void TestCoilUpdateOperation()
{
UpdateCoilsToDataStore testObject = new UpdateCoilsToDataStore();
bool actualStatus = testObject.UpdateCoils(UpdateCoilsToDataStore.TagName, UpdateCoilsToDataStore.ParameterNames, UpdateCoilsToDataStore.FunctionCode);
bool expectedStatus = true;
Assert.AreEqual(expectedStatus, actualStatus);
}
}


Can you please help me to resolve this problem.
Thanks.










share|improve this question














I have created the Slave Simulator Application using Winforms and had to add the Unit Test Project to it.



I have added the Unit Test Project and also added the proper reference of my application.But when I run the test case, I am getting the error as " Program Does not Contain Static Main method suitable for entry point".I have changed Output type to "Windows Application" and there is a Program.cs(which includes main method) in my Application.



following is my Unit test project code I have written



public class UnitTest1
{
[TestMethod]
public void TestCoilUpdateOperation()
{
UpdateCoilsToDataStore testObject = new UpdateCoilsToDataStore();
bool actualStatus = testObject.UpdateCoils(UpdateCoilsToDataStore.TagName, UpdateCoilsToDataStore.ParameterNames, UpdateCoilsToDataStore.FunctionCode);
bool expectedStatus = true;
Assert.AreEqual(expectedStatus, actualStatus);
}
}


Can you please help me to resolve this problem.
Thanks.







c# winforms unit-testing






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 5:55









poojapooja

134




134








  • 1





    A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

    – Amy
    Nov 22 '18 at 6:00











  • "I have changed Output type to "Windows Application" - big mistake

    – T.S.
    Nov 22 '18 at 6:31














  • 1





    A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

    – Amy
    Nov 22 '18 at 6:00











  • "I have changed Output type to "Windows Application" - big mistake

    – T.S.
    Nov 22 '18 at 6:31








1




1





A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

– Amy
Nov 22 '18 at 6:00





A unit test project isnt typically executable. It's a library, and you run the tests using a test runner, such as one built into VS.

– Amy
Nov 22 '18 at 6:00













"I have changed Output type to "Windows Application" - big mistake

– T.S.
Nov 22 '18 at 6:31





"I have changed Output type to "Windows Application" - big mistake

– T.S.
Nov 22 '18 at 6:31












1 Answer
1






active

oldest

votes


















3














Do not run the unit test project, it is class library project we can run test by test using Text Explorer instead of running whole project



Add Unit test project, from Test template



enter image description here



After creating unit test project, write your unit test.



[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Your logic
Assert.AreEqual(1, 1);
}
}


Build your project, do not run it.



Now use your Text explorer to run particular test.



enter image description here






share|improve this answer
























  • Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

    – Prasad Telkikar
    Nov 22 '18 at 6:13











  • Thank you !!, It worked there was some error in my code.Thanks again.

    – pooja
    Nov 22 '18 at 8:49












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424673%2ferrorcannot-find-static-main-in-unit-test-of-winforms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Do not run the unit test project, it is class library project we can run test by test using Text Explorer instead of running whole project



Add Unit test project, from Test template



enter image description here



After creating unit test project, write your unit test.



[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Your logic
Assert.AreEqual(1, 1);
}
}


Build your project, do not run it.



Now use your Text explorer to run particular test.



enter image description here






share|improve this answer
























  • Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

    – Prasad Telkikar
    Nov 22 '18 at 6:13











  • Thank you !!, It worked there was some error in my code.Thanks again.

    – pooja
    Nov 22 '18 at 8:49
















3














Do not run the unit test project, it is class library project we can run test by test using Text Explorer instead of running whole project



Add Unit test project, from Test template



enter image description here



After creating unit test project, write your unit test.



[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Your logic
Assert.AreEqual(1, 1);
}
}


Build your project, do not run it.



Now use your Text explorer to run particular test.



enter image description here






share|improve this answer
























  • Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

    – Prasad Telkikar
    Nov 22 '18 at 6:13











  • Thank you !!, It worked there was some error in my code.Thanks again.

    – pooja
    Nov 22 '18 at 8:49














3












3








3







Do not run the unit test project, it is class library project we can run test by test using Text Explorer instead of running whole project



Add Unit test project, from Test template



enter image description here



After creating unit test project, write your unit test.



[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Your logic
Assert.AreEqual(1, 1);
}
}


Build your project, do not run it.



Now use your Text explorer to run particular test.



enter image description here






share|improve this answer













Do not run the unit test project, it is class library project we can run test by test using Text Explorer instead of running whole project



Add Unit test project, from Test template



enter image description here



After creating unit test project, write your unit test.



[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
//Your logic
Assert.AreEqual(1, 1);
}
}


Build your project, do not run it.



Now use your Text explorer to run particular test.



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 '18 at 6:03









Prasad TelkikarPrasad Telkikar

2,368522




2,368522













  • Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

    – Prasad Telkikar
    Nov 22 '18 at 6:13











  • Thank you !!, It worked there was some error in my code.Thanks again.

    – pooja
    Nov 22 '18 at 8:49



















  • Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

    – Prasad Telkikar
    Nov 22 '18 at 6:13











  • Thank you !!, It worked there was some error in my code.Thanks again.

    – pooja
    Nov 22 '18 at 8:49

















Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

– Prasad Telkikar
Nov 22 '18 at 6:13





Try to debug your test code, because following all steps mentioned in my answer won't give you error which you mentioned in your question. I believe error is from your code not from test project

– Prasad Telkikar
Nov 22 '18 at 6:13













Thank you !!, It worked there was some error in my code.Thanks again.

– pooja
Nov 22 '18 at 8:49





Thank you !!, It worked there was some error in my code.Thanks again.

– pooja
Nov 22 '18 at 8:49




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424673%2ferrorcannot-find-static-main-in-unit-test-of-winforms%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)