haskell - HUnit testing with file dependent tests -


i have lexer, , wish test against set of known test cases. these held in subdirectory ./test_src/ , , each has extension testname.txt

what i'd paths relevant test cases:

gettestfiles :: io [filepath] find (extension ==? ".txt") "/path/to/test_src/" 

and create hunit testlist containing hunit testcases each assertion created via function along lines of

testmylexer :: io filepath -> assertion 

something along lines of

mytest :: [io filepath] -> test mytest = testlist $ fmap testcase $ fmap testmylexer  

where seem failng in approach seems first require follwoing function, , mapping on result:

unabletodothis :: io [filepath] -> [io filepath] 

i've strong suspicion approach i'm following impossible, seems require escaping io monad, i'm asking is:

  1. is approach viable, if missing?
  2. if not, how go solving problem? must pretty common avoid hard coding in test cases

usually if wrapped io a values in arguments you're probably doing wrong. both testmylexer , mytest can pure, instead of

testmylexer :: io filepath -> assertion mytest :: [io filepath] -> test 

do

testmylexer :: filepath -> assertion mytest :: [filepath] -> test 

then it's matter of using bind gettestfiles extract [filepath]:

do     files <- gettestfiles     runtesttt $ mytest files 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -