-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test framework and Unit test for Core functionality:
*Added first test with Junit *Added core test with Junit *Updated CONTRIBUTING.md with testing instruction
- Loading branch information
1 parent
be449b1
commit cb9a626
Showing
7 changed files
with
86 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
import com.company.HTMLBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.apache.commons.io.FileUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class HTMLBuilderTest { | ||
|
||
@Test | ||
void processInput() { | ||
void testProcessInput() throws IOException { | ||
HTMLBuilder.processInput("sources/Sample.txt","testDir"); | ||
File target = new File("dist/Sample.html"); | ||
assertTrue(FileUtils.contentEquals(target,new File("testDir/Sample.html"))); | ||
} | ||
|
||
@Test | ||
void fileNameReader() { | ||
void testFileNameReader() { | ||
String[] fileName1 = {"example", "file", "name.txt"}; | ||
assertEquals("example file name.txt",HTMLBuilder.fileNameReader(fileName1)); | ||
|
||
String[] fileName2 = {"sample.md"}; | ||
assertEquals("sample.md",HTMLBuilder.fileNameReader(fileName2)); | ||
} | ||
|
||
@Test | ||
void writeHtmlHeader() { | ||
void testWriteHtmlHeader() { | ||
} | ||
|
||
@Test | ||
void writeHtmlFoot() { | ||
void testWriteHtmlFoot() { | ||
} | ||
} |
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,34 @@ | ||
package com.company; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.*; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TextUtilsTest { | ||
|
||
@Test | ||
void createHtmlFromTxt() throws IOException { | ||
File targetText = new File("/testDir/targetText.txt"); | ||
File txtFile = new File("/testDir/sample.txt"); | ||
File htmlFile = new File("/testDir/sample.html"); | ||
htmlFile.createNewFile(); | ||
BufferedWriter writeSample = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(txtFile), "UTF-8")); | ||
writeSample.write("This is a Title of the Sample Text"); | ||
writeSample.newLine(); | ||
writeSample.newLine(); | ||
writeSample.write("First Paragraph."); | ||
writeSample.write("This is a sample test"); | ||
writeSample.newLine(); | ||
writeSample.write("2. Sample text"); | ||
writeSample.newLine(); | ||
writeSample.close(); | ||
|
||
TextUtils.createHtmlFromTxt(txtFile,""); | ||
|
||
|
||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("testDir/sample.html"), "UTF-8")); | ||
System.out.println(reader.readLine()); | ||
} | ||
} |
Empty file.
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,4 @@ | ||
This is a Title of the Sample Text | ||
|
||
First Paragraph.This is a sample test | ||
2. Sample text |