I have a bunch of functions like: method1, method2, method3. For all of them there are HUnit test functions like: testMethod1, testMethod2, testMethod3.

testMethod1 = TestCase $
  assertEqual "testmethod1" ...

testMethod2 = TestCase $
  assertEqual "testmethod2" ...

testMethod3 = TestCase $
  assertEqual "testmethod3" ...

I would like to avoid redundant copying of function's name as prefix of error message and call it something like that:

testMethod1 = TestCase $
  assertEqual_ ...

How can it be achieved (any "magic" trick is appreciated)?

So actually question is how can function name be taken inside of it's definition?


Update.

It's not actually clear from original question, that I wanna handle that type of situation too:

tProcess = TestCase $ do
  assertEqual "tProcess" testResult $ someTest
  assertEqual "tProcess" anotherTestResult $ anotherTest
  assertEqual "tProcess" resultAgain $ testAgain

Finally I want to write something like that:

tProcess = TestCase $ do
  assertEqual_ testResult $ someTest
  assertEqual_ anotherTestResult $ anotherTest
  assertEqual_ resultAgain $ testAgain
Edit
Report