Nice programing

MSTest : 테스트가로드되지 않았거나 선택한 테스트가 비활성화 되었기 때문에 테스트가 실행되지 않습니다.

nicepro 2020. 11. 26. 19:52
반응형

MSTest : 테스트가로드되지 않았거나 선택한 테스트가 비활성화 되었기 때문에 테스트가 실행되지 않습니다.


다음 구조의 AC # 솔루션이 있습니다.

mySolution
  myProject
  myProject.MSTests
    References
      Microsoft.VisualStudio.QualityTools.UnitTestFramework
    sutMSTests.cs

sutMSTests.cs :

[TestClass()] 
public class sutMSTests
{
    [TestMethod]
    public void MyTest0()
    {
        Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(4, 2 + 2);
    } 
}

Test, Run, All Tests In Solution을 통해 테스트를 실행하려고하면 VS2008 상태 줄에 다음이 표시됩니다.

테스트가로드되지 않았거나 선택한 테스트가 비활성화 되었기 때문에 테스트가 실행되지 않습니다.

테스트, Windows, 테스트보기에는 테스트가 표시되지 않습니다.

참고 : Microsoft의 마법사를 사용하는 대신 수동으로 테스트를 만들었습니다 (xUnit.net에서 작동).

손으로 만든 MSTest 설정을 마법사를 사용하여 생성 한 다른 테스트 설정과 비교했는데 충분히 유사한 것으로 보입니다 .

질문 : 위의 오류 메시지의 가장 가능성있는 원인은 무엇입니까?

편집 2010-02-25 : 추가 정보 : 솔루션 항목 폴더를
마우스 오른쪽 단추로 클릭하고 추가, 새 프로젝트를 선택하고 Test Projects, Test Documents :: Visual Studio Test Project 템플릿을 입력합니다.

새 프로젝트의 기본값은 테스트 "TestMethod1"이 감지되고 통과되었습니다.
그러나 테스트가 표시되지 않았으므로 테스트 메서드를 복사하여 기본 테스트 테스트 프로젝트 "TestProject1"에 붙여 넣었습니다.

내 테스트가 "TestProject"에서 감지되었지만 원래 위치가 아닙니다.

"TestProject1"의 파일, 구성 및 설정을 직접 만든 테스트 프로젝트와 밀접하게 비교했습니다.

이 시점에서 쉽게 감지 할 수없는 Visual Studio 테스트 프로젝트 템플릿에 의해 일부 설정이 이루어 졌다고 생각 합니다.

Visual Studio 테스트 프로젝트 템플릿으로 테스트 프로젝트를 만드는 것만큼이나 손으로 테스트 프로젝트를 만드는 것이 쉽습니다.

참고 : Visual Studio 테스트 프로젝트 템플릿을 사용하는 것에 반대하는 것이 아닙니다. 저에게는 imho가 훨씬 더 나은 프로그래머가 되었기 때문에 커튼 뒤에 무엇이 있는지 이해하고 싶습니다.


Google 직원을위한 또 다른 문제입니다.이 문제는 내 문제로 판명되었으며, 당황 스러울 정도로 저를 괴롭 혔습니다. 테스트 프로젝트가 사용중인 솔루션 구성에서 빌드하도록 설정되어 있는지 확인합니다. 테스트 어셈블리가 빌드되지 않으면 VS는 존재하지 않는 어셈블리에서 테스트를 찾을 수 없으며 잠시 동안 벽에 머리를 부딪 힐 것입니다 :-)


조금 늦었을 수도 있지만,이 질문은 Google에서 잘 나오고 있습니다. 저는 미래의 Google 직원을 위해 약간의 부스러기를 던질 것이라고 생각했습니다.

Bryan Cook은 MS 테스트 프로젝트를 수동으로 생성하는 방법 에 대한 블로그 게시물에서 ProjectTypeGuids를 확인할 것을 제안합니다 . 분명히 필요한 마법 GUID는 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}C # 및 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}VB 용입니다. 자세한 내용은 그의 블로그 게시물을 참조하십시오.

블로그 게시물이 사라지는 경우 csproj 파일의 기본 속성 그룹에 다음 요소를 추가해야합니다.

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Google 직원을위한 또 다른 아이디어입니다. 내 문제는 무시 된 테스트를 다시 실행하려고했습니다. 무시 레이블을 제거하면 동일한 MS 오류 메시지가 발생합니다. 테스트를 자동으로 다시 활성화하지 않습니다. 이 기사는 마지막 단계를 안내합니다. http://richallen.blogspot.com/2008/05/ms-test-re-enabling-ignored-tests.html


Visual Studio가 제대로 작동한다면 필요하지 않더라도 수정은 간단합니다.

특히이 기사에서 다른 사람들이 기여한 내용을 요약 하면 , 궁극적으로 저에게 도움 이 된 내용은 다음 과 같습니다.

  • 구성 관리자를 사용하여 사용중인 구성 및 플랫폼 (예 : configuration = Debug 및 platform = x86)에서 빌드하도록 테스트 프로젝트가 선택되었는지 확인합니다.
  • 메소드가 a에 속 하고 속성을 사용하지 않고 [TestClass]모두 표시되어 있는지 확인하십시오.[TestMethod][Ignore]
  • 테스트보기를 사용하여 테스트를 찾습니다. 테스트보기
  • 속성 창 ( F4)을 열고 테스트가 활성화되어 있는지 확인합니다.활성화 됨

원래 포스터는 이렇게했지만, 나는 이것을하지 않고 여기에 도착했습니다.

[TestClass]최상위에 선언되고 범위가 공개되어 있는지 확인하십시오 .

namespace XYZ.API.Repository.Tests
{
    [TestClass()]
    public class ClientTests
    {

같은 메시지를 받았는데 네트워크 드라이브에 단위 테스트 프로젝트가 있다는 것이 밝혀졌습니다. 로컬로 이동하면 정상적으로 작동했습니다. 이 오류가 발생하면 시도해 볼 수 있습니다. 남자


방금 수동으로 수행했습니다.

다음 코드를 사용하여 새 C # 클래스 라이브러리 프로젝트를 만들었습니다.

namespace SO_Answer
{
    public class Class1
    {
        public void Test()
        {
            var k = "Hello";
        }
    }
}

프로젝트를 저장 한 다음 'File-> Add-> New Project'로 이동하여 'Test Project'를 선택했습니다. VS가 단위 테스트 프로젝트를 만든 후 앞서 만든 클래스 라이브러리 프로젝트에 대한 참조를 추가했습니다.

내 테스트에서 다음 코드가 있습니다.

namespace Unit_Test
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class UnitTest1
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        #endregion

        /// <summary>
        /// The test method 1.
        /// </summary>
        [TestMethod]
        public void TestMethod1()
        {
            var f = new Class1();

        }
    }
}

내가 추가 한 유일한 코드는 using 문과 var f = new Class1();문입니다. MSTest 실행기를 보면 TestMethod1나타납니다.

I can't think of a reason why your unit tests are not being picked up. The only time I've had this is because I was using the MSTest runner to try and view NUnit tests by mistake. Try starting from scratch.


This could be another reason. Check whether the solution is running on 64bit. If so change it to x86.


This must be a bug and is an absolute pain especially as you have to reenable every single test method individually. However a bit iof lateral thinking produced a better solution - rename the test class and rebuild. Then rename it back. Seems to work. Ooops - no it doesn't. Renaming the class works but when it's renamed back it reverts to the original settings. The trick is to close down Visual Studio and delete the .vsmdi (visual studio test meta data) file. This will be regenrated.


When you run into this issue, in Visual Studio, you have to create a Test Project. 1. Select Test in Tool bar and choose "New Test". Create your project and at this point create your test method. It should work after this point.


For posterity: I just found that marking tests as static made them silently fail to appear in the test list. Apparently that isn't allowed.


None of the other answers worked for me. I kept getting the following message in the output window:

------ Discover test started ------
========== Discover test finished: 2 found (0:00:00.1310428) ==========
No tests found to run.

In my case, the problem only occurred after I created a new configuration called 0-Local. I had to add <DebugSymbols>true</DebugSymbols to the relevant section of my csproj file, so it looks like this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == '0-Local|AnyCPU'">
  <DebugSymbols>true</DebugSymbols>
  <OutputPath>bin\0-Local\</OutputPath>
</PropertyGroup>

Do you have a VSMDI file in your solution? I believe this file is required (NOT VERIFIED).


this is typical problem i have faced too. but the easiest solution I followed as my own is...just to build the project once and rebuild it again. so that you can resolve it.


Had this same issue but reading over the previous answers, everything looked good.

In my case, I had just run the test suite made a small change, built the solution and tried to run the test. No go. I tried building a couple more times and looking for problems other people had tried. Still no go.

I hit enter in one of my test methods to add a new and hit F6 to build the solution and clicked run Unit Tests.

Bingo! Everything ran smoothly.


I was making use of a public TestContext TestContext method to write to the test output and changed the scope to private. This made every test not discoverable. Changing it back to public helped.


NUnit을 사용하는 Google 사용자, 특히 MS Unit 테스트에서 NUnit으로 마이그레이션 한 사용자를위한 또 다른 방법입니다. 프로젝트 파일에서 프로젝트를 MS Test 프로젝트로 식별하는 프로젝트 유형 Guid를 제거하십시오.

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

코드가 CLI (관리 C ++)이고 테스트 클래스가 추상 기본 클래스에서 상속되는 경우 테스트 클래스가 기본의 순수 가상 메서드를 구현하는지 확인합니다. 구현하지 않은 경우 "실행할 테스트를 찾을 수 없음"메시지가 표시 될 수 있습니다.

참고 URL : https://stackoverflow.com/questions/2314887/mstest-no-tests-are-run-because-no-tests-are-loaded-or-the-selected-tests-are-d

반응형