Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UnitTesting and Debug tests for Unity2022 #2418

Open
wants to merge 1 commit into
base: net233
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ val TestMethod.unityEnvironment: UnityTestEnvironmentInstance?
method.annotations.filterIsInstance<UnityTestEnvironment>().firstOrNull())

enum class UnityVersion(val version: String) {
V2020("2020")
V2020("2020"),
V2022("2022")
}
2 changes: 1 addition & 1 deletion rider/src/test/kotlin/integrationTests/DebuggerTest2020.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.io.File

@TestEnvironment(platform = [PlatformType.WINDOWS_ALL, PlatformType.MAC_OS_ALL])
class DebuggerTest2020 : IntegrationTestWithUnityProjectBase() {
override fun getSolutionDirectoryName() = "UnitTesting/Project2020"
override fun getSolutionDirectoryName() = "UnityDebugAndUnitTesting/Project"
override val unityMajorVersion = UnityVersion.V2020

override fun preprocessTempDirectory(tempDir: File) {
Expand Down
58 changes: 58 additions & 0 deletions rider/src/test/kotlin/integrationTests/DebuggerTest2022.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package integrationTests

import base.integrationTests.*
import com.intellij.xdebugger.XDebuggerManager
import com.intellij.xdebugger.breakpoints.XLineBreakpoint
import com.jetbrains.rider.debugger.breakpoint.DotNetLineBreakpointProperties
import com.jetbrains.rider.plugins.unity.debugger.breakpoints.UnityPausepointBreakpointType
import com.jetbrains.rider.plugins.unity.debugger.breakpoints.convertToLineBreakpoint
import com.jetbrains.rider.test.annotations.TestEnvironment
import com.jetbrains.rider.test.enums.PlatformType
import com.jetbrains.rider.test.scriptingApi.*
import org.testng.annotations.AfterMethod
import org.testng.annotations.Test
import java.io.File

@TestEnvironment(platform = [PlatformType.WINDOWS_ALL, PlatformType.MAC_OS_ALL])
class DebuggerTest2022 : IntegrationTestWithUnityProjectBase() {
override fun getSolutionDirectoryName() = "UnityDebugAndUnitTesting/Project"
override val unityMajorVersion = UnityVersion.V2022

override fun preprocessTempDirectory(tempDir: File) {
super.preprocessTempDirectory(tempDir)

val newBehaviourScript = "NewBehaviourScript.cs"
val sourceScript = testCaseSourceDirectory.resolve(newBehaviourScript)
if (sourceScript.exists()) {
sourceScript.copyTo(tempDir.resolve("Assets").resolve(newBehaviourScript), true)
}
}

@Test
fun checkBreakpoint() {
attachDebuggerToUnityEditorAndPlay(
{
toggleBreakpoint("NewBehaviourScript.cs", 8)
toggleBreakpoint("NewBehaviourScript.cs", 15)
},
{
waitForPause()
dumpFullCurrentData()
resumeSession()
waitForPause()
dumpFullCurrentData()
resumeSession()
}, testGoldFile)
}

@AfterMethod(alwaysRun = true)
fun removeAllUnityPausepoints() {
XDebuggerManager.getInstance(project).breakpointManager.allBreakpoints.filter {
it.type is UnityPausepointBreakpointType
}.forEach {
@Suppress("UNCHECKED_CAST")
convertToLineBreakpoint(project, it as XLineBreakpoint<DotNetLineBreakpointProperties>)
}
removeAllBreakpoints()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.testng.annotations.Test

@TestEnvironment(platform = [PlatformType.WINDOWS_ALL, PlatformType.MAC_OS_ALL])
class UnitTestingTest2020 : IntegrationTestWithUnityProjectBase() {
override fun getSolutionDirectoryName() = "UnitTesting/Project2020"
override fun getSolutionDirectoryName() = "UnityDebugAndUnitTesting/Project"
override val unityMajorVersion = UnityVersion.V2020
@Test
fun checkRunAllTestsFromProject() {
Expand Down
66 changes: 66 additions & 0 deletions rider/src/test/kotlin/integrationTests/UnitTestingTest2022.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package integrationTests

import base.integrationTests.IntegrationTestWithUnityProjectBase
import base.integrationTests.UnityVersion
import com.jetbrains.rider.test.annotations.Mute
import com.jetbrains.rider.test.annotations.TestEnvironment
import com.jetbrains.rider.test.enums.PlatformType
import com.jetbrains.rider.test.scriptingApi.RiderUnitTestScriptingFacade
import com.jetbrains.rider.test.scriptingApi.changeFileContent
import com.jetbrains.rider.test.scriptingApi.withUtFacade
import org.testng.annotations.Test

@TestEnvironment(platform = [PlatformType.WINDOWS_ALL, PlatformType.MAC_OS_ALL])
class UnitTestingTest2022 : IntegrationTestWithUnityProjectBase() {
override fun getSolutionDirectoryName() = "UnityDebugAndUnitTesting/Project"
override val unityMajorVersion = UnityVersion.V2022
@Test
fun checkRunAllTestsFromProject() {
withUtFacade(project) {
it.waitForDiscovering()

val session = it.runAllTestsInProject(
"Tests",
5,
RiderUnitTestScriptingFacade.defaultTimeout,
5
)
it.compareSessionTreeWithGold(session, testGoldFile)
}
}

@Mute("RIDER-95762")
@Test(description = "RIDER-54359")
fun checkRefreshBeforeTest() {
withUtFacade(project) {
val file = activeSolutionDirectory.resolve("Assets").resolve("Tests").resolve("NewTestScript.cs")
it.waitForDiscovering()
it.runAllTestsInProject(
"Tests",
5,
RiderUnitTestScriptingFacade.defaultTimeout,
5
)

it.closeAllSessions()

changeFileContent(project, file) {
it.replace("NewTestScriptSimplePasses(", "NewTestScriptSimplePasses2(")
}

it.runAllTestsInProject(
"Tests",
5,
RiderUnitTestScriptingFacade.defaultTimeout, -1
)
val session2 = it.runAllTestsInProject(
"Tests",
5,
RiderUnitTestScriptingFacade.defaultTimeout,
5
)

it.compareSessionTreeWithGold(session2, testGoldFile)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--> NewBehaviourScript.cs:8(110,129) // Debug.Log("Start");
NewBehaviourScript.Start() in , Assembly-CSharp.dll
+Active scene = SampleScene (Assets/Scenes/SampleScene.unity): null
+this.gameObject = Main Camera (active: true, layer: 0): null
+this = enabled: true, gameObject: Main Camera: NewBehaviourScript

--> NewBehaviourScript.cs:15(310,336) // Debug.Log(binaryNotation);
NewBehaviourScript.Update() in , Assembly-CSharp.dll
+Active scene = SampleScene (Assets/Scenes/SampleScene.unity): null
+this.gameObject = Main Camera (active: true, layer: 0): null
+this = enabled: true, gameObject: Main Camera: NewBehaviourScript
binaryNotation = 2000000: int

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-ROOT
-Tests
-Tests
-NewTestScript
NewTestScriptSimplePasses2
NewTestScriptWithEnumeratorPasses
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-ROOT
-Tests
-Tests
-NewTestScript
NewTestScriptSimplePasses
NewTestScriptWithEnumeratorPasses

This file was deleted.