Commit cf02611b authored by Sergey Karashevich's avatar Sergey Karashevich
Browse files

[gui-test] comeback to teamcity

parent aee239e5
Branches unavailable Tags unavailable
No related merge requests found
Showing with 148 additions and 3 deletions
+148 -3
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.codehaus.gant.GantBinding
import org.jetbrains.intellij.build.BuildMessages
import org.jetbrains.intellij.build.BuildOptions
import org.jetbrains.intellij.build.TestingOptions
import org.jetbrains.intellij.build.TestingTasks
import org.jetbrains.intellij.build.impl.CompilationContextImpl
import org.jetbrains.jps.gant.JpsGantTool
import org.jetbrains.jps.idea.IdeaProjectLoader
import org.jetbrains.jps.model.JpsProject
import java.util.function.BiFunction
/**
* Compiles the sources and runs tests from 'community' project. Look at org.jetbrains.intellij.build.TestingOptions to see which options are
* supported.
*/
target("default": "Run tests") {
String home = IdeaProjectLoader.guessHome(this)
String outputDir = "$home/out/tests"
def compilationOptions = new BuildOptions()
// compilationOptions.useCompiledClassesFromProjectOutput = true
// compilationOptions.incrementalCompilation = true
// def context = CompilationContextImpl.create(home, home, outputDir, this)
GantBinding binding = (GantBinding) this.binding
binding.includeTool << JpsGantTool
def context = CompilationContextImpl.create(binding.ant as AntBuilder, binding.projectBuilder, binding.project, binding.global, home, home,
{ p, m -> outputDir } as BiFunction<JpsProject, BuildMessages, String>, compilationOptions)
def testingOptions = new TestingOptions()
// testingOptions.setTestGroups("GUI_TESTS")
// testingOptions.setTestPatterns("com.intellij.testGuiFramework.tests.community.*")
TestingTasks.create(context, testingOptions).runTests([], "testGuiFramework", null)
}
......@@ -60,6 +60,11 @@ class TestingOptions {
*/
String mainModule = System.getProperty("intellij.build.test.main.module", OLD_MAIN_MODULE)
/**
* Specifies a custom Test Suite.
*/
String bootstrapSuite = System.getProperty("intellij.build.test.bootstrap.suite", BOOTSTRAP_SUITE_DEFAULT)
private static final String OLD_TEST_GROUP = System.getProperty("idea.test.group", "ALL_EXCLUDE_DEFINED")
private static final String OLD_TEST_PATTERNS = System.getProperty("idea.test.patterns")
private static final String OLD_PLATFORM_PREFIX = System.getProperty("idea.platform.prefix")
......@@ -67,4 +72,6 @@ class TestingOptions {
private static final boolean OLD_SUSPEND_DEBUG_PROCESS = System.getProperty("debug.suspend", "n") == "y"
private static final String OLD_JVM_MEMORY_OPTIONS = System.getProperty("test.jvm.memory")
private static final String OLD_MAIN_MODULE = System.getProperty("module.to.make")
public static final String BOOTSTRAP_SUITE_DEFAULT = "com.intellij.tests.BootstrapTests"
}
......@@ -147,7 +147,11 @@ class TestingTasksImpl extends TestingTasks {
---------------------------------------^------^------^------^------^------^------^----------------------------------------
""")
}
runJUnitTask(jvmArgs, systemProperties, bootstrapClasspath)
if (isBootstrapSuiteDefault())
runJUnitTask(jvmArgs, systemProperties, bootstrapClasspath)
else
//run other suites instead of BootstrapTests
runJUnitTask(jvmArgs, systemProperties, testsClasspath)
}
@CompileDynamic
......@@ -170,7 +174,7 @@ class TestingTasksImpl extends TestingTasks {
}
}
test(name: 'com.intellij.tests.BootstrapTests')
test(name: options.bootstrapSuite)
}
}
......@@ -199,4 +203,8 @@ class TestingTasksImpl extends TestingTasks {
ant.project.addReference(junitTaskLoaderRef, new AntClassLoader(ant.project.getClass().getClassLoader(), ant.project, pathJUnit))
ant.taskdef(name: "junit", classname: "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask", loaderRef: junitTaskLoaderRef)
}
private boolean isBootstrapSuiteDefault() {
return options.bootstrapSuite == TestingOptions.BOOTSTRAP_SUITE_DEFAULT
}
}
\ No newline at end of file
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.testGuiFramework.tests.community
import com.intellij.testGuiFramework.framework.RunWithIde
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.launcher.ide.IdeType
import org.junit.Assert.assertTrue
import org.junit.Test
import java.util.regex.Pattern
@RunWithIde(IdeType.IDEA_COMMUNITY)
class CommandLineProjectTest: GuiTestCase() {
val testProjectName = "test-cmd-template"
val codeText: String = """package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
}
}"""
@Test
fun testProjectCreate() {
welcomeFrame {
actionLink("Create New Project").click()
dialog("New Project") {
jList("Java").clickItem("Java")
button("Next").click()
checkbox("Create project from template").click()
jList("Command Line App").clickItem("Command Line App")
button("Next").click()
typeText(testProjectName)
button("Finish").click()
}
}
ideFrame {
toolwindow(id = "Project") {
projectView {
path(project.name, "src", "com.company", "Main").doubleClick()
}
}
editor {
moveTo(118)
moveTo(121)
}
val editorCode = editor.getCurrentFileContents(false)
assertTrue(codeText.lowerCaseNoSpace() == editorCode!!.lowerCaseNoSpace())
closeProject()
}
}
fun String.lowerCaseNoSpace() = this.toLowerCase().removeSpaces()
fun String.removeSpaces(): String {
val WHITE_SPACE_PATTERN = Pattern.compile("\\s")
return WHITE_SPACE_PATTERN.matcher(this).replaceAll("")
}
}
\ No newline at end of file
......@@ -23,5 +23,5 @@ import org.junit.runners.Suite
@RunWith(GuiTestSuite::class)
@RunWithIde(IdeType.IDEA_COMMUNITY)
@Suite.SuiteClasses()
@Suite.SuiteClasses(CommandLineProjectTest::class)
class CommunityTestSuite
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment