When I run a unit test for a new created project then it shows me the wrong result (Says All Tests are passed).
If you see in the image below 4 is expected while 6+2 surely not 4.
Now when I run the same test from Gradle right menu. It shows me the correct result that test has failed.
Did I do anything wrong or is this an android studio bug?
Edit
Run configuration image
You need to add -ea option in the "VM options" box in your 3rd image. This is to enable assertion feature for the JVM. Without this -ea, JVM just ignore assertion statement. When you run the test with gradle, it used a default configuration so that's why your test was run correctly.