ma2gedev / power_assert_ex

Power Assert in Elixir. Shows evaluation results each expression.
https://github.com/ma2gedev/power_assert_ex
Other
214 stars 6 forks source link

Is it possible to use the PowerAssert assert macro while using another test framework, such as ExSpec or ShouldI? #1

Closed lpil closed 8 years ago

lpil commented 8 years ago

Thanks :)

ma2gedev commented 8 years ago

Thank you for questions :)

I'm checking ExSpec and ShouldI sources. Both framework depend on ExUnit so maybe it is possible. But there is no easy way to use PowerAssert, working a lot to import PowerAssert.Assertion.assert instead of ExUnit.Assertions.assert.

It may be helpful PowerAssert.AssertionEraser code to except ExUnit.Assertions.assert. https://github.com/ma2gedev/power_assert_ex/blob/1eeed55fd67830b02c0b0404dbb2c38cd3014d56/lib/power_assert/assertion_eraser.ex#L4

lpil commented 8 years ago

Can I just export it as power_assert or something instead of overriding assert?

ma2gedev commented 8 years ago

It's nice idea! I created tiny sample using with ExSpec. https://gist.github.com/ma2gedev/b0ad5fb1c81c5804d1d6

Test code uses passert method wrapping PowerAssert.Assertion.assert and worked correctly. Maybe work with ShouldI though i didn't try with ShouldI.

lpil commented 8 years ago

I think it would be nice if the README documented how to use just the new assert macro in ExUnit, and then people can work it out from there. It would be nice if it were as simple as useing a module.

power_assert seems like a long name, and passert doesn't seem very elixir-y. What ought it be called? assert!?

ma2gedev commented 8 years ago

Thank you for feedback :smiley: I wrote document and commited options to avoid conflict problem. The name of new macro is power_assert though it is long name.

Document is here. https://github.com/ma2gedev/power_assert_ex#how-to-use-other-framework-depending-on-exunit-such-as-exspec

Also published version 0.0.4 included this option to hex.

lpil commented 8 years ago

Thanks!

ma2gedev commented 8 years ago

@lpil

Currently it is possible to use the PowerAssert assert with ExSpec and ShouldI. This is available after PowerAssertEx version 0.0.8. If you still are interested in power assert, please try it.

If you use ExSpec, see this section. Or ShouldI, see this section.

Sample code is here: With ExSpec With ShouldI

Thanks!!

lpil commented 8 years ago

I'm actually migrating to ExUnit, but thank you :)

ma2gedev commented 8 years ago

Thanks for you comment. Also thank you opened this issue, now i understood certainly about import's except option behavior. :bow:

lpil commented 8 years ago

Fantastic :D