Add file comparison feature to surround with tests

This commit is contained in:
Nikolay Krasko
2018-12-12 18:21:57 +03:00
parent 0482fe9414
commit 0a8e29838f
@@ -23,12 +23,14 @@ import com.intellij.lang.surroundWith.Surrounder;
import com.intellij.openapi.editor.SelectionModel;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiElement;
import com.intellij.rt.execution.junit.FileComparisonFailure;
import com.intellij.testFramework.LightCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.codeInsight.surroundWith.expression.*;
import org.jetbrains.kotlin.idea.codeInsight.surroundWith.statement.*;
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import java.io.File;
import java.util.List;
@@ -122,7 +124,14 @@ public abstract class AbstractSurroundWithTest extends LightCodeInsightTestCase
private void invokeSurroundAndCheck(@NotNull String path, @NotNull Surrounder surrounder) {
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
checkResultByFile(path + ".after");
String filePath = path + ".after";
try {
checkResultByFile(filePath);
}
catch (FileComparisonFailure fileComparisonFailure) {
KotlinTestUtils.assertEqualsToFile(new File(filePath), getEditor());
}
}
@Nullable