Search in sources :

Example 1 with TestFileScope

use of com.google.jstestdriver.idea.rt.util.TestFileScope in project intellij-plugins by JetBrains.

the class JstdSettings method build.

@NotNull
public static JstdSettings build(@NotNull Map<TestRunner.ParameterKey, String> parameters) {
    String serverUrl = parameters.get(TestRunner.ParameterKey.SERVER_URL);
    if (serverUrl == null) {
        throw new RuntimeException(TestRunner.ParameterKey.SERVER_URL + " parameter must be specified");
    }
    String configFilesStr = notNullize(parameters.get(TestRunner.ParameterKey.CONFIG_FILES));
    List<String> paths = EscapeUtils.split(configFilesStr, ',');
    List<File> configFiles = Lists.newArrayList();
    for (String path : paths) {
        File file = new File(path);
        if (file.isFile()) {
            configFiles.add(file);
        }
    }
    if (configFiles.isEmpty()) {
        throw new RuntimeException("No valid config files found");
    }
    String runAllConfigsInDirectoryPath = parameters.get(TestRunner.ParameterKey.ALL_CONFIGS_IN_DIRECTORY);
    File runAllConfigsInDirectory = null;
    if (runAllConfigsInDirectoryPath != null && !runAllConfigsInDirectoryPath.isEmpty()) {
        runAllConfigsInDirectory = new File(runAllConfigsInDirectoryPath);
        if (!runAllConfigsInDirectory.isDirectory()) {
            runAllConfigsInDirectory = null;
        }
    }
    String testsScope = parameters.get(TestRunner.ParameterKey.TESTS);
    final TestFileScope testFileScope;
    if (testsScope == null) {
        testFileScope = TestFileScope.allScope();
    } else {
        testFileScope = TestFileScope.deserialize(testsScope);
    }
    String coverageFilePath = notNullize(parameters.get(TestRunner.ParameterKey.COVERAGE_OUTPUT_FILE));
    File ideCoverageFile = null;
    List<String> excludedPaths = Collections.emptyList();
    if (!coverageFilePath.isEmpty()) {
        ideCoverageFile = new File(coverageFilePath);
        String joinedPaths = notNullize(parameters.get(TestRunner.ParameterKey.COVERAGE_EXCLUDED_PATHS));
        excludedPaths = EscapeUtils.split(joinedPaths, ',');
    }
    boolean debug = Boolean.TRUE.toString().equals(parameters.get(TestRunner.ParameterKey.DEBUG));
    return new JstdSettings(serverUrl, configFiles, runAllConfigsInDirectory, testFileScope, ideCoverageFile, excludedPaths, debug);
}
Also used : TestFileScope(com.google.jstestdriver.idea.rt.util.TestFileScope) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TestFileScope

use of com.google.jstestdriver.idea.rt.util.TestFileScope in project intellij-plugins by JetBrains.

the class JstdRunProfileState method createParameterMap.

@NotNull
private Map<TestRunner.ParameterKey, String> createParameterMap(@NotNull String serverUrl) throws ExecutionException {
    Map<TestRunner.ParameterKey, String> parameters = Maps.newLinkedHashMap();
    parameters.put(TestRunner.ParameterKey.SERVER_URL, serverUrl);
    TestType testType = myRunSettings.getTestType();
    if (testType == TestType.ALL_CONFIGS_IN_DIRECTORY) {
        parameters.put(TestRunner.ParameterKey.ALL_CONFIGS_IN_DIRECTORY, myRunSettings.getDirectory());
    }
    List<VirtualFile> jstdConfigs = JstdSettingsUtil.collectJstdConfigs(myEnvironment.getProject(), myRunSettings);
    if (jstdConfigs.isEmpty()) {
        throw new ExecutionException("Can't find JsTestDriver configuration file.");
    }
    parameters.put(TestRunner.ParameterKey.CONFIG_FILES, joinJstdConfigs(jstdConfigs));
    TestFileScope testFileScope = buildTestFileScope(myEnvironment.getProject(), myRunSettings);
    if (!testFileScope.isAll()) {
        parameters.put(TestRunner.ParameterKey.TESTS, testFileScope.serialize());
    }
    if (myCoverageFilePath != null) {
        parameters.put(TestRunner.ParameterKey.COVERAGE_OUTPUT_FILE, myCoverageFilePath);
        if (!myRunSettings.getFilesExcludedFromCoverage().isEmpty()) {
            String excludedPaths = EscapeUtils.join(myRunSettings.getFilesExcludedFromCoverage(), ',');
            parameters.put(TestRunner.ParameterKey.COVERAGE_EXCLUDED_PATHS, excludedPaths);
        }
    }
    if (myDebug) {
        parameters.put(TestRunner.ParameterKey.DEBUG, Boolean.TRUE.toString());
    }
    return parameters;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TestFileScope(com.google.jstestdriver.idea.rt.util.TestFileScope) TestType(com.google.jstestdriver.idea.execution.settings.TestType) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with TestFileScope

use of com.google.jstestdriver.idea.rt.util.TestFileScope in project intellij-plugins by JetBrains.

the class TestFileScopeTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    String testCaseName = "Difference";
    String testMethodName = "test One value on left and other value on right, gives empty object";
    Map<String, Set<String>> methodByCaseMap = Collections.singletonMap(testCaseName, Collections.singleton(testMethodName));
    TestFileScope testFileScope = TestFileScope.customScope(methodByCaseMap);
    String serialized = testFileScope.serialize();
    TestFileScope another = TestFileScope.deserialize(serialized);
    Assert.assertEquals(testFileScope, another);
}
Also used : TestFileScope(com.google.jstestdriver.idea.rt.util.TestFileScope) Set(java.util.Set) Test(org.junit.Test)

Aggregations

TestFileScope (com.google.jstestdriver.idea.rt.util.TestFileScope)3 NotNull (org.jetbrains.annotations.NotNull)2 TestType (com.google.jstestdriver.idea.execution.settings.TestType)1 ExecutionException (com.intellij.execution.ExecutionException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 Set (java.util.Set)1 Test (org.junit.Test)1