모든 개발에서 그렇듯이 패키지에는 테스트를 추가하는 것이 좋습니다. 패키지에 대한 테스트를 설정하려면 다음의 세 가지 사항을 따라야 합니다.
Editor 및 Runtime 하위 폴더에 있는 패키지의 Tests 폴더에 테스트 파일을 추가할 수 있습니다. 예를 들어 테스트가 포함된 단순한 패키지는 다음과 같은 모습일 수 있습니다.
MyPackage
├── package.json
├── Editor
│ ├── MyPackage.Editor.asmdef
│ └── EditorExample.cs
├── Runtime
│ ├── MyPackage.Runtime.asmdef
│ └── RuntimeExample.cs
└── Tests
├── Editor
│ ├── MyPackage.EditorTests.asmdef
│ └── EditorExampleTest.cs
└── Runtime
├── MyPackage.RuntimeTests.asmdef
└── RuntimeExampleTest.cs
각 하위 폴더에는 Editor 및 Runtime 어셈블리에 레퍼런스를 제공하는 .asmdef
파일이 들어 있어야 합니다. 또한 어셈블리 정의 파일은 테스트 어셈블리 파일에 대한 레퍼런스를 제공합니다. 자세한 내용은 테스트용 어셈블리 정의 파일을 참조하십시오.
어셈블리 정의 파일을 직접 편집할 수 있습니다. 다음의 레퍼런스를 추가해야 합니다.
속성 | 타입 | 설명 |
---|---|---|
name | String | 파일 확장자가 없는 어셈블리 이름입니다. |
references | 문자열 배열 | Editor 및 Runtime 어셈블리에 대한 레퍼런스입니다. 어셈블리 정의 파일에는 Editor 또는 Runtime 테스트용인지 여부에 따라 다른 레퍼런스가 필요합니다. - Editor 테스트의 경우 패키지의 Editor 및 Runtime 어셈블리에 레퍼런스를 추가합니다. - Runtime 테스트의 경우 패키지의 Runtime 어셈블리에만 추가합니다. |
optionalUnityReferences | 문자열 배열 | 이 Unity 레퍼런스 리스트는 어셈블리를 테스트 어셈블리로 표시하기 위해 “TestAssemblies”를 포함해야 합니다. 이 속성은 unit.framework.dll 및 UnityEngine.TestRunner.dll 라이브러리에 대한 레퍼런스를 어셈블리 정의에 추가합니다. |
includePlatforms | 문자열 배열 | Editor 테스트의 경우 이 플랫폼 리스트는 “Editor” 플랫폼을 포함해야 합니다. |
팁: 인스펙터에서 어셈블리 정의 파일도 편집할 수 있습니다. 자세한 내용은 어셈블리 정의를 참조하십시오.
에디터 테스트 .asmdef
파일은 다음과 같은 모습입니다.
{
"name": "MyPackage.Editor.Tests",
"references": [
"MyPackage.Editor",
"MyPackage"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": []
}
런타임 테스트 .asmdef
파일은 다음과 같은 모습입니다.
{
"name": "MyPackage.Tests",
"references": [
"MyPackage"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [],
"excludePlatforms": []
}
내장된 패키지의 경우에는 내장된 패키지가 개발 중이므로 테스트를 명시적으로 활성화할 필요가 없습니다.
하지만 다른 종속성 타입의 경우에는 testables 속성을 프로젝트 매니페스트에 추가하고 실행할 테스트가 있는 패키지의 이름을 추가해야 합니다. 여기에는 프로젝트의 직접 및 간접 종속성이 포함됩니다. 예를 들어 다음과 같습니다.
{
"dependencies": {
"com.unity.some-package": "1.0.0",
"com.unity.other-package": "2.0.0",
"com.unity.yet-another-package": "3.0.0",
},
"testables": ["com.unity.some-package", "com.unity.other-package"]
}
이 예시에서는 Unity 테스트 프레임워크 패키지에 com.unity.some-package 및 com.unity.other-package 패키지에 대한 테스트를 추가합니다.
참고: 테스트 프레임워크가 testables 속성에 대한 변경 사항을 즉시 식별하지 못할 때도 있기 때문에 패키지를 다시 임포트해야 할 수 있습니다.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.