-
-
Notifications
You must be signed in to change notification settings - Fork 18
Update Test dependencies and Test cases #73
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||||||
package io.xmake.project.toolkit | ||||||||||
|
||||||||||
import junit.framework.TestCase.assertEquals | ||||||||||
import junit.framework.TestCase.assertNotNull | ||||||||||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These imports are from the older JUnit 3 For even more idiomatic Kotlin, you could use the
Suggested change
|
||||||||||
import kotlinx.coroutines.CoroutineScope | ||||||||||
import kotlinx.coroutines.Dispatchers | ||||||||||
import org.junit.Before | ||||||||||
import org.junit.Test | ||||||||||
import org.junit.runner.RunWith | ||||||||||
import org.junit.runners.JUnit4 | ||||||||||
|
||||||||||
@RunWith(JUnit4::class) | ||||||||||
class ToolkitManagerTest { | ||||||||||
|
||||||||||
private lateinit var toolkitManager: ToolkitManager | ||||||||||
|
||||||||||
@Before | ||||||||||
fun setUp() { | ||||||||||
toolkitManager = ToolkitManager(CoroutineScope(Dispatchers.Default)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||||||||||
toolkitManager.loadState(ToolkitManager.State()) | ||||||||||
} | ||||||||||
|
||||||||||
@Test | ||||||||||
fun `test register and find toolkit`() { | ||||||||||
val localToolkit = Toolkit( | ||||||||||
name = "Local xmake", | ||||||||||
host = ToolkitHost(ToolkitHostType.LOCAL), | ||||||||||
path = "/usr/local/bin/xmake", | ||||||||||
version = "3.0.2" | ||||||||||
) | ||||||||||
|
||||||||||
toolkitManager.registerToolkit(localToolkit) | ||||||||||
|
||||||||||
val registeredToolkits = toolkitManager.getRegisteredToolkits() | ||||||||||
assertEquals("Should have one registered toolkit", 1, registeredToolkits.size) | ||||||||||
assertEquals("The registered toolkit should be the one we added", localToolkit, registeredToolkits.first()) | ||||||||||
|
||||||||||
val foundToolkit = toolkitManager.findRegisteredToolkitById(localToolkit.id) | ||||||||||
assertNotNull("Should find the toolkit by its ID", foundToolkit) | ||||||||||
assertEquals("The found toolkit should be the same as the original", localToolkit, foundToolkit) | ||||||||||
} | ||||||||||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change replaces the
kotlin-test-junit5
dependency withjunit:4.13.2
, standardizing on JUnit 4. While this resolves dependency issues, it would be beneficial to consider migrating to JUnit 5. JUnit 5 is the current standard for JVM testing and offers numerous improvements, such as a more flexible extension model and better support for Kotlin. Since you are in the process of rewriting tests, it might be a good opportunity to adopt this more modern framework.