-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
diktat-test-framework
(#1785)
- removed `diktat-test-framework` - added `diktat-test-common` with common util methods for tests - removed usage of diff multiplatform tool
- Loading branch information
Showing
41 changed files
with
172 additions
and
961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
id("com.saveourtool.diktat.buildutils.kotlin-jvm-configuration") | ||
id("com.saveourtool.diktat.buildutils.code-quality-convention") | ||
id("com.saveourtool.diktat.buildutils.publishing-default-configuration") | ||
} | ||
|
||
project.description = "Diktat common for tests" | ||
|
||
dependencies { | ||
api(projects.diktatCommon) | ||
implementation(libs.kotlin.logging) | ||
implementation(libs.junit.jupiter.api) | ||
implementation(libs.assertj.core) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...-test/src/main/kotlin/com/saveourtool/diktat/test/framework/processing/TestFileContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* It's a class container for test file content. | ||
* Plus exception cases when resource or file is not found | ||
*/ | ||
|
||
package com.saveourtool.diktat.test.framework.processing | ||
|
||
import com.saveourtool.diktat.test.framework.util.describe | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.assertj.core.api.SoftAssertions.assertSoftly | ||
import org.intellij.lang.annotations.Language | ||
|
||
import java.nio.file.Path | ||
|
||
import kotlin.io.path.absolutePathString | ||
|
||
/** | ||
* A base interface for content of test file | ||
*/ | ||
sealed interface TestFileContent { | ||
/** | ||
* Asserts [TestFileContent] that content are equal | ||
*/ | ||
fun assertSuccessful() | ||
} | ||
|
||
/** | ||
* Implementation of [TestFileContent] when resources are not found | ||
* | ||
* @param expectedResource | ||
* @param expectedPath | ||
* @param actualResource | ||
* @param actualPath | ||
*/ | ||
data class NotFoundResourcesTestFileContent( | ||
private val expectedResource: String, | ||
private val expectedPath: Path?, | ||
private val actualResource: String, | ||
private val actualPath: Path?, | ||
) : TestFileContent { | ||
override fun assertSuccessful() { | ||
assertSoftly { softly -> | ||
softly.assertThat(expectedPath) | ||
.describedAs("Expected resource <%s>", expectedResource) | ||
.isNotNull | ||
softly.assertThat(actualPath) | ||
.describedAs("Actual resource <%s>", actualResource) | ||
.isNotNull | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Implementation of [TestFileContent] when files are not found | ||
* | ||
* @param expectedPath | ||
* @param actualPath | ||
*/ | ||
data class NotFoundFilesTestFileContent( | ||
private val expectedPath: Path, | ||
private val actualPath: Path, | ||
) : TestFileContent { | ||
override fun assertSuccessful() { | ||
assertSoftly { softly -> | ||
softly.assertThat(expectedPath) | ||
.describedAs("Expected file <%s>", expectedPath.absolutePathString()) | ||
.isRegularFile | ||
softly.assertThat(actualPath) | ||
.describedAs("Actual resource <%s>", actualPath.absolutePathString()) | ||
.isRegularFile | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* The result of files being compared by their content. | ||
* | ||
* @param actualContent the actual file content (possibly slightly different | ||
* from the original after `diktat:check` is run). | ||
* @param expectedContent the expected file content without warns. | ||
*/ | ||
data class DefaultTestFileContent( | ||
@Language("kotlin") private val actualContent: String, | ||
@Language("kotlin") private val expectedContent: String, | ||
) : TestFileContent { | ||
override fun assertSuccessful() { | ||
assertThat(actualContent) | ||
.describedAs("lint result for ", actualContent.describe()) | ||
.isEqualTo(expectedContent) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...st/kotlin/com/saveourtool/diktat/ruleset/chapter3/ClassLikeStructuresOrderRuleWarnTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.