-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1483 from madsboddum/chore/testing/acceptance-tes…
…t-rules ArchUnit rules for testcases
- Loading branch information
Showing
4 changed files
with
150 additions
and
2 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
61 changes: 61 additions & 0 deletions
61
src/test/java/com/projectswg/holocore/architecture/testing/AcceptanceTestRules.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,61 @@ | ||
/*********************************************************************************** | ||
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com * | ||
* * | ||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * | ||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * | ||
* Our goal is to create an emulator which will provide a server for players to * | ||
* continue playing a game similar to the one they used to play. We are basing * | ||
* it on the final publish of the game prior to end-game events. * | ||
* * | ||
* This file is part of Holocore. * | ||
* * | ||
* --------------------------------------------------------------------------------* | ||
* * | ||
* Holocore is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU Affero General Public License as * | ||
* published by the Free Software Foundation, either version 3 of the * | ||
* License, or (at your option) any later version. * | ||
* * | ||
* Holocore is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Affero General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Affero General Public License * | ||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. * | ||
***********************************************************************************/ | ||
package com.projectswg.holocore.architecture.testing | ||
|
||
import com.projectswg.common.network.packets.SWGPacket | ||
import com.projectswg.holocore.headless.HeadlessSWGClient | ||
import com.projectswg.holocore.test.runners.AcceptanceTest | ||
import com.tngtech.archunit.junit.ArchTest | ||
import com.tngtech.archunit.lang.ArchRule | ||
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition | ||
import me.joshlarson.jlcommon.control.Intent | ||
|
||
object AcceptanceTestRules { | ||
@ArchTest | ||
val useHeadlessSwgClient: ArchRule = ArchRuleDefinition.classes().that() | ||
.areAssignableTo(AcceptanceTest::class.java) | ||
.should() | ||
.dependOnClassesThat() | ||
.resideInAPackage(HeadlessSWGClient::class.java.packageName) | ||
.because("acceptance tests should use the ${HeadlessSWGClient::class.simpleName} to perform actions") | ||
|
||
@ArchTest | ||
val doNotDirectlyReferencePackets: ArchRule = ArchRuleDefinition.noClasses().that() | ||
.areAssignableTo(AcceptanceTest::class.java) | ||
.should() | ||
.dependOnClassesThat() | ||
.areAssignableTo(SWGPacket::class.java) | ||
.because("we want to re-use packet handling from test to test and we centralize this in ${HeadlessSWGClient::class.simpleName}") | ||
|
||
@ArchTest | ||
val doNotDirectlyReferenceIntents: ArchRule = ArchRuleDefinition.noClasses().that() | ||
.areAssignableTo(AcceptanceTest::class.java) | ||
.should() | ||
.dependOnClassesThat() | ||
.areAssignableTo(Intent::class.java) | ||
.because("interact with the server through the ${HeadlessSWGClient::class.simpleName} using packets instead of directly using intents") | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/com/projectswg/holocore/architecture/testing/JUnitRules.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,45 @@ | ||
/*********************************************************************************** | ||
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com * | ||
* * | ||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * | ||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * | ||
* Our goal is to create an emulator which will provide a server for players to * | ||
* continue playing a game similar to the one they used to play. We are basing * | ||
* it on the final publish of the game prior to end-game events. * | ||
* * | ||
* This file is part of Holocore. * | ||
* * | ||
* --------------------------------------------------------------------------------* | ||
* * | ||
* Holocore is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU Affero General Public License as * | ||
* published by the Free Software Foundation, either version 3 of the * | ||
* License, or (at your option) any later version. * | ||
* * | ||
* Holocore is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Affero General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Affero General Public License * | ||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. * | ||
***********************************************************************************/ | ||
package com.projectswg.holocore.architecture.testing | ||
|
||
import com.tngtech.archunit.junit.ArchTest | ||
import com.tngtech.archunit.lang.ArchRule | ||
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition | ||
|
||
object JUnitRules { | ||
@ArchTest | ||
val doNotUseJUnit4: ArchRule = ArchRuleDefinition.noClasses().should() | ||
.dependOnClassesThat() | ||
.resideInAPackage("org.junit") | ||
.because("we use JUnit 5") | ||
|
||
@ArchTest | ||
val doNotUseJUnit3: ArchRule = ArchRuleDefinition.noClasses().should() | ||
.dependOnClassesThat() | ||
.resideInAPackage("junit.framework") | ||
.because("we use JUnit 5") | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/com/projectswg/holocore/architecture/testing/TestingArchitectureTest.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,42 @@ | ||
/*********************************************************************************** | ||
* Copyright (c) 2023 /// Project SWG /// www.projectswg.com * | ||
* * | ||
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * | ||
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * | ||
* Our goal is to create an emulator which will provide a server for players to * | ||
* continue playing a game similar to the one they used to play. We are basing * | ||
* it on the final publish of the game prior to end-game events. * | ||
* * | ||
* This file is part of Holocore. * | ||
* * | ||
* --------------------------------------------------------------------------------* | ||
* * | ||
* Holocore is free software: you can redistribute it and/or modify * | ||
* it under the terms of the GNU Affero General Public License as * | ||
* published by the Free Software Foundation, either version 3 of the * | ||
* License, or (at your option) any later version. * | ||
* * | ||
* Holocore is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Affero General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Affero General Public License * | ||
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. * | ||
***********************************************************************************/ | ||
package com.projectswg.holocore.architecture.testing | ||
|
||
import com.tngtech.archunit.core.importer.ImportOption | ||
import com.tngtech.archunit.junit.AnalyzeClasses | ||
import com.tngtech.archunit.junit.ArchTest | ||
import com.tngtech.archunit.junit.ArchTests | ||
|
||
@AnalyzeClasses(packages = ["com.projectswg.holocore"], importOptions = [ImportOption.OnlyIncludeTests::class]) | ||
class TestingArchitectureTest { | ||
|
||
@ArchTest | ||
val acceptanceTestRules: ArchTests = ArchTests.`in`(AcceptanceTestRules::class.java) | ||
|
||
@ArchTest | ||
val junitRules: ArchTests = ArchTests.`in`(JUnitRules::class.java) | ||
} |