Skip to content
Snippets Groups Projects
Commit 10342ec5 authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Extended tests.

parent 048dc6d5
No related branches found
No related tags found
No related merge requests found
package nl.lumc.sasc.biopet.extensions.clever package nl.lumc.sasc.biopet.extensions.clever
import java.io.File
import java.nio.file.Paths
import org.scalatest.Matchers import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test import org.testng.annotations.Test
import scala.io.Source
/** /**
* Created by wyleung on 13-5-16. * Created by wyleung on 13-5-16.
*/ */
class CleverFixVCFTest extends TestNGSuite with Matchers { class CleverFixVCFTest extends TestNGSuite with Matchers {
/** Returns the absolute path to test resource directory as a File object */
private[clever] val resourceDir: File = new File(Paths.get(getClass.getResource(".").toURI).toString)
/** Given a resource file name, returns the the absolute path to it as a File object */
private[clever] def resourceFile(p: String): File = new File(resourceDir, p)
val rawCleverVCF = resourceFile("test.clever.vcf")
val expectedCleverVCF = resourceFile("expectedresult.clever.vcf")
@Test @Test
def replacementSucces = { def replacementSucces = {
CleverFixVCF.replaceHeaderLine( CleverFixVCF.replaceHeaderLine(
...@@ -31,4 +44,39 @@ class CleverFixVCFTest extends TestNGSuite with Matchers { ...@@ -31,4 +44,39 @@ class CleverFixVCFTest extends TestNGSuite with Matchers {
) should equal(vcfRecordExpected + "\n") ) should equal(vcfRecordExpected + "\n")
} }
@Test
def mainTest = {
val output = File.createTempFile("clever", ".test.vcf")
output.deleteOnExit()
val result = CleverFixVCF.main(Array(
"-i", rawCleverVCF.getAbsolutePath,
"-o", output.getAbsolutePath,
"-s", "testsample"
))
val exp = Source.fromFile(expectedCleverVCF).getLines()
val obs = Source.fromFile(output).getLines()
(exp zip obs).foreach(_ match {
case (a,b) => {
a shouldEqual(b)
}
case _ =>
})
}
@Test
def javaCommand = {
val output = File.createTempFile("clever", ".test.vcf")
output.deleteOnExit()
val cfvcf = new CleverFixVCF(null)
cfvcf.input = rawCleverVCF
cfvcf.output = output
cfvcf.sampleName = "testsample"
cfvcf.cmdLine should include ("'-s' 'testsample'")
cfvcf.cmdLine should include (s"'-i' '${rawCleverVCF}'")
cfvcf.cmdLine should include (s"'-o' '${output}'")
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment