Skip to content

Commit

Permalink
feat: TMS-29071: migrate to 2.1.0 plugin; add pycharm configuration;
Browse files Browse the repository at this point in the history
multiple configuration build enabled;
add settings dropdown list for selected generator;
  • Loading branch information
taipoxinous committed Nov 18, 2024
1 parent b7a95b4 commit f29d7ab
Show file tree
Hide file tree
Showing 21 changed files with 339 additions and 97 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

# Build plugin
- name: Build Plugin
run: ./gradlew buildPlugin --no-build-cache --no-configuration-cache
# Build plugin for PyCharm
- name: Build Plugin for PyCharm
run: |
./gradlew buildPlugin -PisPyCharm=true --no-build-cache --no-configuration-cache
for f in testit_management-*.zip; do mv "$f" "${f/testit_management-/testit_management_PyCharm-}"; done
# Build plugin for IDEA
- name: Build Plugin for IDEA
run: |
./gradlew buildPlugin -PisIDEA=true --no-build-cache --no-configuration-cache
for f in testit_management-*.zip; do mv "$f" "${f/testit_management-/testit_management_IDEA-}"; done
- name: Upload Release Asset
env:
Expand Down
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ project's work items and hierarchies, generate unit tests for selected work item
>
> Click the <kbd>Watch</kbd> button on the top to be notified about releases containing new features and fixes.

### We added PyCharm and pytest support recently (1.0.12)!

## Compatibility

| Test IT | Plugin Test IT Management |
Expand All @@ -20,6 +23,7 @@ project's work items and hierarchies, generate unit tests for selected work item
You can download the latest version of the Test IT Management plugin from
the [releases](https://github.com/testit-tms/testit-management/releases) page.


## Setup

1. Configure connection in the `File -> Settings -> Tools -> Test IT` menu.
Expand Down
59 changes: 50 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.intellij)
alias(libs.plugins.kotlin)
id("org.jetbrains.intellij.platform") version "2.1.0"
}

fun properties(key: String) = providers.gradleProperty(key)
Expand All @@ -16,9 +17,32 @@ version = properties("pluginVersion").get()
repositories {
mavenLocal()
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

dependencies {
intellijPlatform {
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })
instrumentationTools()

var ideaVersion = properties("ideaVersion")
var pycharmVersion = properties("pycharmVersion")


if (project.hasProperty("isPyCharm")) {
logger.quiet("PyCharm build enabled")
create(IntelliJPlatformType.PyCharmCommunity, pycharmVersion)
} else if (project.hasProperty("isIDEA")) {
logger.quiet("IDEA build enabled")
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
} else {
logger.quiet("Default IDEA build enabled")
create(IntelliJPlatformType.IntellijIdeaCommunity, ideaVersion)
}
}
api(libs.okhttp)
implementation(kotlin("stdlib-jdk8"))
implementation(libs.jsoup)
Expand All @@ -28,20 +52,35 @@ dependencies {
testCompileOnly(libs.testit.common)
}

intellij {
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")
plugins = properties("platformPlugins").map {
it.split(',').map(String::trim).filter(String::isNotEmpty)
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")

description = "The Test IT Management plugin is a powerful tool for managing test cases. It provides an ability to browse work items hierarchies, generate unit tests for selected scenarios."
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
vendor {
name = "Test IT"
// email = ""
url = "https://testit.software"
}
}
downloadSources = true
// publishing { }
// signing { }
}


kotlin {
jvmToolchain(properties("javaVersion").get().toInt())
}

// Access the environment variable
var buildEnv = System.getenv("BUILD_ENV") ?: "development"

// Modify the buildPlugin task to set the zip filename dynamically

tasks {
wrapper {
gradleVersion = properties("gradleVersion").get()
Expand All @@ -52,12 +91,12 @@ tasks {
}

patchPluginXml {
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}

publishPlugin {

dependsOn("patchChangelog")
token = environment("PUBLISH_TOKEN")
channels = properties("pluginVersion").map {
Expand Down Expand Up @@ -120,3 +159,5 @@ tasks {
useJUnitPlatform()
}
}


6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
pluginVersion=1.0.11
pluginVersion=1.0.12
pluginGroup=ru.testit.management
pluginName=testit_management
pluginRepositoryUrl=https://github.com/testit-tms/testit-management/
gradleVersion=8.8
pluginSinceBuild=231
pluginUntilBuild=244.*
platformType=IC
platformVersion=2024.1.3
pycharmVersion=2024.1.3
ideaVersion=2024.1.3
platformPlugins=
platformBundledPlugins=
javaEncoding=UTF-8
javaVersion=17
kotlin.code.style=official
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ testit-common = "latest.release"

# plugins
kotlin = "2.0.0"
intellij = "1.17.3"

[libraries]
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" }
Expand All @@ -18,5 +17,4 @@ testit-api = { group = "ru.testit", name = "testit-api-client", version.ref = "t
testit-common = { group = "ru.testit", name = "testit-java-commons", version.ref = "testit-common" }

[plugins]
intellij = { id = "org.jetbrains.intellij", version.ref = "intellij" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

rootProject.name = "Test IT Management"
rootProject.name = "testit_management"
10 changes: 6 additions & 4 deletions src/main/kotlin/ru/testit/management/clients/TmsClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ object TmsClient {
try {
client = getNewApiClient(url, privateToken)
val project = ProjectsApi(client).getProjectById(projectId)
// return project.id.toString()

val errorMessage = if (project == null) {
MessagesUtils.get("api.validation.project.null.text")
Expand All @@ -33,10 +34,11 @@ object TmsClient {

return errorMessage
} catch (exception: Throwable) {
return String.format(
MessagesUtils.get("api.validation.project.error.text"),
exception.message
)
// return String.format(
// MessagesUtils.get("api.validation.project.error.text"),
// exception.message
// )
return exception.message
} finally {
client?.httpClient?.connectionPool?.evictAll()
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/ru/testit/management/enums/FrameworkOption.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.testit.management.enums

enum class FrameworkOption {
JUNIT {
override fun toString() = "junit"
},
PYTEST {
override fun toString() = "pytest"
}


}
47 changes: 47 additions & 0 deletions src/main/kotlin/ru/testit/management/snippet/JunitSnippet.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ru.testit.management.snippet

import ru.testit.management.utils.CodeSnippetUtils.getTestName
import ru.testit.management.utils.CodeSnippetUtils.tryUpdateLineWithSteps
import ru.testit.management.utils.StringUtils
import ru.testit.management.windows.tools.TmsNodeModel

object JunitSnippet {
const val JUNIT_CODE_SNIPPET = """
@WorkItemIds("globalId")
@Test
public void testName() {
// See work item [globalId] for detailed steps description
// Pre:
// preconditions
// Steps:
// testSteps
// Post:
// postconditions
}
"""


val comparator = { globalId: Long -> "@WorkItemIds(\"$globalId\")" }


fun getNewSnippetJunit(userObject: Any): String {
val model = userObject as TmsNodeModel
val builder = StringBuilder()

JUNIT_CODE_SNIPPET.lines().forEach { line ->
var modifiedLine = line
.replace("testName",
StringUtils.spacesToCamelCase(getTestName(model)))
.replace("globalId", model.globalId.toString())

modifiedLine = tryUpdateLineWithSteps(modifiedLine, model)

if (modifiedLine.isNotBlank()) {
builder.appendLine(modifiedLine)
}
}

return builder.toString().trimIndent()
}

}
52 changes: 52 additions & 0 deletions src/main/kotlin/ru/testit/management/snippet/PytestSnippet.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package ru.testit.management.snippet

import ru.testit.management.utils.CodeSnippetUtils
import ru.testit.management.utils.CodeSnippetUtils.getTestName
import ru.testit.management.utils.CodeSnippetUtils.tryUpdateLineWithSteps
import ru.testit.management.utils.StringUtils
import ru.testit.management.windows.tools.TmsNodeModel

object PytestSnippet {
const val PYTEST_CODE_SNIPPET = """
@testit.externalId("externalId")
@testit.displayName("displayName_")
@testit.title("title_")
@testit.description("description")
@testit.workItemIds("globalId")
def testName():
// See work item [globalId] for detailed steps description
// Pre:
// preconditions
// Steps:
// testSteps
// Post:
// postconditions
"""

val comparator = { globalId: Long -> "@testit.workItemIds(\"$globalId\")" }


fun getNewSnippetPytest(userObject: Any): String {
val model = userObject as TmsNodeModel
val builder = StringBuilder()

val testName = getTestName(model)
PYTEST_CODE_SNIPPET.lines().forEach { line ->
var modifiedLine = line
.replace("testName",
StringUtils.spacesToSnakeCase(testName))
.replace("globalId", model.globalId.toString())
.replace("title_", testName)
.replace("displayName_", testName)

modifiedLine = tryUpdateLineWithSteps(modifiedLine, model)

if (modifiedLine.isNotBlank()) {
builder.appendLine(modifiedLine)
}
}

return builder.toString().trimIndent()
}
}
Loading

0 comments on commit f29d7ab

Please sign in to comment.