Skip to content

Commit 4c04f49

Browse files
committed
Playing with the idea of using more natural test names
1 parent 41a4a44 commit 4c04f49

17 files changed

+65
-67
lines changed

src/test/kotlin/com/demonwav/mcdev/framework/TestUtil.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,4 @@ fun createLibrary(project: Project, name: String): Library {
4242
}
4343

4444
fun String.toSnakeCase(postFix: String = "") =
45-
split("(?=[A-Z])".toRegex())
46-
.map(String::toLowerCase)
47-
.joinToString("_") + postFix
45+
replace(" ", "_") + postFix

src/test/kotlin/com/demonwav/mcdev/platform/mcp/at/AtCommenterTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class AtCommenterTest : BaseMinecraftTest(PlatformType.MCP) {
3333
myFixture.checkResultByFile("${fileName}_after_at.cfg", true)
3434
}
3535

36-
fun testSingleLineComment() = doTest(IdeActions.ACTION_COMMENT_LINE, """
36+
fun `test single line comment`() = doTest(IdeActions.ACTION_COMMENT_LINE, """
3737
public net.mine<caret>craft.entity.Entity field_190534_ay # fire
3838
public net.minecraft.entity.Entity field_70152_a # nextEntityID
3939
""", """
4040
#public net.minecraft.entity.Entity field_190534_ay # fire
4141
public net.minec<caret>raft.entity.Entity field_70152_a # nextEntityID
4242
""")
4343

44-
fun testMultiLineComment() = doTest(IdeActions.ACTION_COMMENT_LINE, """
44+
fun `test multi line comment`() = doTest(IdeActions.ACTION_COMMENT_LINE, """
4545
public net.minecraft.command.CommandHandler func<selection>_71559_a([Ljava/lang/String;)[Ljava/lang/String; # dropFirstString
4646
public net.minecraft.command.CommandHandler func_82370_a(Lnet/minecraft/command/ICommand;[Ljava/lang</selection>/String;)I # getUsernameIndex
4747
public net.minecraft.command.EntitySelector func_82381_h(Ljava/lang/String;)Ljava/util/Map; # getArgumentMap
@@ -51,7 +51,7 @@ class AtCommenterTest : BaseMinecraftTest(PlatformType.MCP) {
5151
public net.minecraft.command.EntitySelector func_82381_h(Ljava/lang/String;)Ljava/util/Map; # getArgumentMap
5252
""")
5353

54-
fun testSingleLinesUncomment() = doTest(IdeActions.ACTION_COMMENT_LINE, """
54+
fun `test single line uncomment`() = doTest(IdeActions.ACTION_COMMENT_LINE, """
5555
public net.minecraft.entity.Entity field_70152_a # nextEntityID
5656
public net.<caret>minecraft.entity.Entity func_190531_bD()I
5757
#public net.minecraft.entity.EntityHanging func_174859_a(Lnet/minecraft/util/EnumFacing;)V # updateFacingWithBoundingBox
@@ -63,7 +63,7 @@ class AtCommenterTest : BaseMinecraftTest(PlatformType.MCP) {
6363
#public net.minecraft.entity.EntityList field_180126_g # stringToIDMapping
6464
""")
6565

66-
fun testMultiLineUncomment() = doTest(IdeActions.ACTION_COMMENT_LINE, """
66+
fun `test multi line uncomment`() = doTest(IdeActions.ACTION_COMMENT_LINE, """
6767
#public net.minecraft<selection>.entity.EntityLivingBase field_70752_e # potionsNeedUpdate
6868
#publi</selection>c net.minecraft.entity.EntityLivingBase field_70755_b # entityLivingToAttack
6969
public net.minecraft.entity.EntityLivingBase func_184583_d(Lnet/minecraft/util/DamageSource;)Z # canBlockDamageSource
@@ -73,7 +73,7 @@ class AtCommenterTest : BaseMinecraftTest(PlatformType.MCP) {
7373
public net.minecraft.entity.EntityLivingBase func_184583_d(Lnet/minecraft/util/DamageSource;)Z # canBlockDamageSource
7474
""")
7575

76-
fun testMultiLineCommentWithComments() = doTest(IdeActions.ACTION_COMMENT_LINE, """
76+
fun `test multi line comment with comments`() = doTest(IdeActions.ACTION_COMMENT_LINE, """
7777
public net.minecraft.entity.EntityLivingBase field_184621_as # HAND_STATES
7878
#public net.minecraft.ent<selection>ity.EntityLivingBase field_184632_c # HEALTH
7979
public net.minecraft.entity.EntityLivingBase field_184633_f # POTION_EFFECTS

src/test/kotlin/com/demonwav/mcdev/platform/mcp/at/AtLexerTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AtLexerTest : LexerTestCase() {
2323
override fun getDirPath() = "src/test/resources/com/demonwav/mcdev/platform/mcp/at/lexer/fixtures"
2424
override fun createLexer() = AtLexerAdapter()
2525

26-
override fun getTestName(lowercaseFirstLetter: Boolean) = super.getTestName(lowercaseFirstLetter).toSnakeCase("_at")
26+
override fun getTestName(lowercaseFirstLetter: Boolean) = super.getTestName(lowercaseFirstLetter).substring(1).toSnakeCase("_at")
2727

2828
// Copied because it wasn't handling the paths correctly
2929
private fun doTest() {
@@ -41,11 +41,11 @@ class AtLexerTest : LexerTestCase() {
4141
UsefulTestCase.assertSameLinesWithFile(dirPath + "/" + getTestName(true) + ".txt", result)
4242
}
4343

44-
fun testClassNames() = doTest()
45-
fun testClassValues() = doTest()
46-
fun testComments() = doTest()
47-
fun testFuncs() = doTest()
48-
fun testKeywords() = doTest()
49-
fun testNames() = doTest()
50-
fun testPrimitives() = doTest()
44+
fun `test class names`() = doTest()
45+
fun `test class values`() = doTest()
46+
fun `test comments`() = doTest()
47+
fun `test funcs`() = doTest()
48+
fun `test keywords`() = doTest()
49+
fun `test names`() = doTest()
50+
fun `test primitives`() = doTest()
5151
}

src/test/kotlin/com/demonwav/mcdev/platform/mcp/at/AtParsingTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import com.intellij.testFramework.ParsingTestCase
1616
class AtParsingTest : ParsingTestCase("com/demonwav/mcdev/platform/mcp/at/parser/fixtures", "cfg", true, AtParserDefinition()) {
1717

1818
override fun getTestDataPath() = "src/test/resources"
19-
override fun getTestName(lowercaseFirstLetter: Boolean) = super.getTestName(lowercaseFirstLetter).toSnakeCase("_at")
19+
override fun getTestName(lowercaseFirstLetter: Boolean) = super.getTestName(lowercaseFirstLetter).substring(1).toSnakeCase("_at")
2020

21-
fun testAsterisks() = doTest(true)
22-
fun testComments() = doTest(true)
23-
fun testFields() = doTest(true)
24-
fun testFuncs() = doTest(true)
25-
fun testKeywords() = doTest(true)
26-
fun testNoValue() = doTest(true)
21+
fun `test asterisks`() = doTest(true)
22+
fun `test comments`() = doTest(true)
23+
fun `test fields`() = doTest(true)
24+
fun `test funcs`() = doTest(true)
25+
fun `test keywords`() = doTest(true)
26+
fun `test no value`() = doTest(true)
2727
}

src/test/kotlin/com/demonwav/mcdev/platform/mixin/AccessorMixinTest.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class AccessorMixinTest : BaseMixinTest() {
4646
test(psiClass!!)
4747
}
4848

49-
fun testAccessorMixin() = doTest("AccessorMixin", """
49+
fun `test accessor mixin`() = doTest("AccessorMixin", """
5050
package test;
5151
5252
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -64,7 +64,7 @@ class AccessorMixinTest : BaseMixinTest() {
6464
assertTrue(psiClass.isAccessorMixin)
6565
}
6666

67-
fun testMissingAnnotation() = doTest("MissingAnnotationAccessorMixin", """
67+
fun `test missing accessor annotation`() = doTest("MissingAnnotationAccessorMixin", """
6868
package test;
6969
7070
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -82,7 +82,7 @@ class AccessorMixinTest : BaseMixinTest() {
8282
assertFalse(psiClass.isAccessorMixin)
8383
}
8484

85-
fun testTargetInterface() = doTest("TargetInterface", """
85+
fun `test accessor target interface`() = doTest("TargetInterface", """
8686
package test;
8787
8888
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -100,7 +100,7 @@ class AccessorMixinTest : BaseMixinTest() {
100100
assertFalse(psiClass.isAccessorMixin)
101101
}
102102

103-
fun testOnlyAccessors() = doTest("AccessorMixin", """
103+
fun `test only accessors`() = doTest("AccessorMixin", """
104104
package test;
105105
106106
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -115,7 +115,7 @@ class AccessorMixinTest : BaseMixinTest() {
115115
assertTrue(psiClass.isAccessorMixin)
116116
}
117117

118-
fun testOnlyInvokers() = doTest("AccessorMixin", """
118+
fun `test only invokers`() = doTest("AccessorMixin", """
119119
package test;
120120
121121
import org.spongepowered.asm.mixin.gen.Invoker;
@@ -130,7 +130,7 @@ class AccessorMixinTest : BaseMixinTest() {
130130
assertTrue(psiClass.isAccessorMixin)
131131
}
132132

133-
fun testNonInterfaceAccessorMixin() = doTest("NonInterfaceAccessorMixin", """
133+
fun `test non-interface accessor mixin`() = doTest("NonInterfaceAccessorMixin", """
134134
package test;
135135
136136
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -146,7 +146,7 @@ class AccessorMixinTest : BaseMixinTest() {
146146
assertFalse(psiClass.isAccessorMixin)
147147
}
148148

149-
fun testNonInterfaceTargetInterface() = doTest("NonInterfaceTargetInterface", """
149+
fun `test non-interface target interface`() = doTest("NonInterfaceTargetInterface", """
150150
package test;
151151
152152
import org.spongepowered.asm.mixin.gen.Accessor;

src/test/kotlin/com/demonwav/mcdev/platform/mixin/InnerClassTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class InnerClassTest : BaseMixinTest() {
5353
}
5454
}
5555

56-
fun testInnerClassInspection() {
56+
fun `test inner class inspection`() {
5757
myFixture.enableInspections(MixinInnerClassInspection::class.java)
5858
myFixture.checkHighlighting(true, false, false)
5959
}

src/test/kotlin/com/demonwav/mcdev/platform/mixin/SuperClassTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class SuperClassTest : BaseMixinTest() {
5858
myFixture.checkHighlighting(true, false, false)
5959
}
6060

61-
fun testNone() {
61+
fun `test no mixin superclass`() {
6262
doTest("""
6363
package test;
6464
@@ -72,7 +72,7 @@ class SuperClassTest : BaseMixinTest() {
7272
}
7373

7474

75-
fun testCool() {
75+
fun `test good mixin superclass`() {
7676
doTest("""
7777
package test;
7878
@@ -85,7 +85,7 @@ class SuperClassTest : BaseMixinTest() {
8585
""")
8686
}
8787

88-
fun testNotItself() {
88+
fun `test mixin not its own superclass`() {
8989
doTest("""
9090
package test;
9191
@@ -98,7 +98,7 @@ class SuperClassTest : BaseMixinTest() {
9898
""")
9999
}
100100

101-
fun testHierarchy() {
101+
fun `test mixin class hierarchy not found`() {
102102
doTest("""
103103
package test;
104104

src/test/kotlin/com/demonwav/mcdev/platform/mixin/implements/DuplicateInterfaceInspectionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DuplicateInterfaceInspectionTest : BaseMixinTest() {
5151
myFixture.checkHighlighting(true, false, false)
5252
}
5353

54-
fun testGood() {
54+
fun `test no highlight on no duplicate interface`() {
5555
doTest("""
5656
package test;
5757
@@ -70,7 +70,7 @@ class DuplicateInterfaceInspectionTest : BaseMixinTest() {
7070
""")
7171
}
7272

73-
fun testBad() {
73+
fun `test highlight on duplicate interface`() {
7474
doTest("""
7575
package test;
7676

src/test/kotlin/com/demonwav/mcdev/platform/mixin/implements/DuplicateInterfacePrefixInspectionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class DuplicateInterfacePrefixInspectionTest : BaseMixinTest() {
5151
myFixture.checkHighlighting(true, false, false)
5252
}
5353

54-
fun testGood() {
54+
fun `test no highlight on no duplicate interface prefix`() {
5555
doTest("""
5656
package test;
5757
@@ -70,7 +70,7 @@ class DuplicateInterfacePrefixInspectionTest : BaseMixinTest() {
7070
""")
7171
}
7272

73-
fun testBad() {
73+
fun `test highlight on duplicate interface prefix`() {
7474
doTest("""
7575
package test;
7676

src/test/kotlin/com/demonwav/mcdev/platform/mixin/implements/EmptyImplementsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class EmptyImplementsTest : BaseMixinTest() {
4343
myFixture.checkHighlighting(true, false, false)
4444
}
4545

46-
fun testEmpty() {
46+
fun `test highlight on empty @Implements`() {
4747
doTest("""
4848
package test;
4949
@@ -59,7 +59,7 @@ class EmptyImplementsTest : BaseMixinTest() {
5959
""")
6060
}
6161

62-
fun testSingle() {
62+
fun `test no highlight with single @Implements`() {
6363
doTest("""
6464
package test;
6565
@@ -75,7 +75,7 @@ class EmptyImplementsTest : BaseMixinTest() {
7575
""")
7676
}
7777

78-
fun testMultiple() {
78+
fun `test no highlight with mutli @Implements`() {
7979
doTest("""
8080
package test;
8181

0 commit comments

Comments
 (0)