Can you mix TestNG and JUnit Assertions together within the same Test / Framework?
For example lets say I have developed a framework, is it possible to have the following:
Thanks For your help
Keep in mind what the essence of both frameworks is: they execute testcases.
Of course you can put whatever annotations you want into your code. But the point is: those annotations by themselves mean nothing. They are just markers on classes/method definitions.
It is the underlying framework, that checks for their presence at runtime and does "something" when this or that annotation is found.
Meaning: in order for JUnit resp. TestNG annotations to cause the desired effects at runtime ... you have to run the test either within the JUnit or the TestNG framework. But - you can't run both frameworks in parallel, in the same JVM, on the same source code.
In other words: if there is a need to do so, then you have to separate your testcases into different buckets: one for JUnit tests; one for TestNG tests. But forget about mixing things on a lower level!
And even when it would be technically possible to run both frameworks "together" in one JVM - you still do not want to do that. Simply because those frameworks are not designed to support this requirement; and because nobody else does it; and therefore your chances of hitting all kinds of obvious and subtle bugs is way too high!
But I have to admit: I misread the question. If its solely about dealing with those asserts, then I agree to Grasshoper's comment to this answer; I do not see a hard technical reason for that to not work.
You can use any assertion library you want in your tests: TestNG, JUnit, AssertJ, Hamcrest, ...
It is possible to run JUnit tests with TestNG too because TestNG supports JUnit if you configure it well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With