Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing frameworks: Is Google Truth a substitute for JUnit? How to I write test methods and test suites?

I came across Google Truth https://google.github.io/truth/ and thought to try it out. I read the information on that site but still have a basic question.

Is Truth a substitute for JUnit? How should I write the @test methods and test suites the way I write in JUnit and automate the test execution say through Jenkins? Or is it that Truth is just about making your assertion code beautiful and everything else stays the same?

Does Truth still needs help of JUnit framework (or something like JUnit)?

Thanks!

like image 361
Saurabh Patil Avatar asked Jan 22 '17 04:01

Saurabh Patil


People also ask

What is com Google Truth?

What is Truth? Truth makes your test assertions and failure messages more readable. Similar to AssertJ, it natively supports many JDK and Guava types, and it is extensible to others. Truth is owned and maintained by the Guava team. It is used in the majority of the tests in Google's own codebase.

Which function is used in JUnit to compare expected and actual result?

You use an assert method, provided by JUnit or another assert framework, to check an expected result versus the actual result. These method calls are typically called asserts or assert statements.

Which of the following is a JUnit extension?

There are several JUnit extensions such as: JWebUnit. XMLUnit. Cactus.


1 Answers

No, Google Truth isn't a full replacement for JUnit/TestNG. Truth is an assertion framework which allows you to write assertions more flexibly (see their Comparison page for details).

Truth however doesn't have a concept of tests/test suites/test runs/... so you'll still need a testing framework (like JUnit or TestNG) to actually execute your tests.

like image 74
ralph.mayr Avatar answered Sep 28 '22 06:09

ralph.mayr