Skip to content

Commit

Permalink
Added missing test cases for no directory found to hit 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Rd4dev committed Sep 5, 2024
1 parent 99c0371 commit 72d0a2b
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class WikiTableOfContentsCheckTest {

@Before
fun setUp() {
tempFolder.newFolder("wiki")
System.setOut(PrintStream(outContent))
}

Expand All @@ -30,8 +29,22 @@ class WikiTableOfContentsCheckTest {
System.setOut(originalOut)
}

@Test
fun testWikiTOCCheck_noWikiDirExists_printsNoContentFound() {
runScript()
assertThat(outContent.toString().trim()).isEqualTo("No contents found in the Wiki directory.")
}

@Test
fun testWikiTOCCheck_noWikiDirectory_printsNoContentFound() {
tempFolder.newFile("wiki")
runScript()
assertThat(outContent.toString().trim()).isEqualTo("No contents found in the Wiki directory.")
}

@Test
fun testWikiTOCCheck_validWikiTOC_checkPass() {
tempFolder.newFolder("wiki")
val file = tempFolder.newFile("wiki/wiki.md")
file.writeText(
"""
Expand All @@ -55,6 +68,7 @@ class WikiTableOfContentsCheckTest {

@Test
fun testWikiTOCCheck_missingWikiTOC_returnsNoTOCFound() {
tempFolder.newFolder("wiki")
val file = tempFolder.newFile("wiki/wiki.md")
file.writeText(
"""
Expand All @@ -76,6 +90,7 @@ class WikiTableOfContentsCheckTest {

@Test
fun testWikiTOCCheck_mismatchWikiTOC_checkFail() {
tempFolder.newFolder("wiki")
val file = tempFolder.newFile("wiki/wiki.md")
file.writeText(
"""
Expand All @@ -101,6 +116,7 @@ class WikiTableOfContentsCheckTest {

@Test
fun testWikiTOCCheck_validWikiTOCWithSeparator_checkPass() {
tempFolder.newFolder("wiki")
val file = tempFolder.newFile("wiki/wiki.md")
file.writeText(
"""
Expand All @@ -124,6 +140,7 @@ class WikiTableOfContentsCheckTest {

@Test
fun testWikiTOCCheck_validWikiTOCWithSpecialCharacter_checkPass() {
tempFolder.newFolder("wiki")
val file = tempFolder.newFile("wiki/wiki.md")
file.writeText(
"""
Expand Down

0 comments on commit 72d0a2b

Please sign in to comment.