How to use assertions to know the bugs in my application

Hello everybody,
Can anybody show me an example of assert commands?
I tried to use it but did not get successful.


Sure, anybody can do that.

But you have not provided the programming language you are using, nor the testing framework.

Do you just want an overview? Basically something like this:

expect(@current_screen).to be_kind_of(ActivationScreen)

This is how I test the screen I’m on. It’s Ruby with Rspec as the testing framework.

Or maybe you’d like to test some localization:

expect(@current_screen.permissions_header.text).to eq(languages.strings[@current_screen.string_map[:perm_head]])


Hello @wreed ,
I an using java.
It will be better for me if you’ll send me the java example with complete example, as i am a beginner.


Ok, so you are using Java, and you don’t have a testing framework. I’m going to recommend TestNg, with the caveat that I’m only recommending it because I’ve used it in the past. I don’t use Java in my current job and have not kept up with the current state of Java testing.

First, here is a good list of Assertions you can choose from in TestNg:

As for how to use them it’s very easy to Google this kind of thing. I expect that you’ll do that, but I’ll add an example or 2 here just to get you going.

Let’s take the examples I did above in Ruby/Rspec. How would they look in Java/TestNg?

import org.testng.Assert;
import org.testng.annotations.Test;
public class ActivationScreenTest {
 public void testActivationScreen(currentScreen) {
public void testActivationScreenLocalization(currentScreen) {
  Assert.assertEquals(currentScreen.permissionsHeader.text, languages.strings[currentScreen.stringMap[permissionsHeader]);

You would have needed to instantiate the currentScreen object in some @Before method (I personally would use a ScreenFactory class to do this), but that’s beyond the scope of ‘Show me an example of an Assert’.

Finally, if you want a more definitive answer on Java/TestNg assertions, might I suggest you post topics on a Java/TestNg board? This one seems good, and I’m sure there are more:

Good luck.

Hello @wreed,
Thanks for the reply.
The example you gave was a bit non understandable for me as it’s totally a new thing for me.
So i googled it and got to learn the basic scenario of assertion that where to use it.
Can you do one thing for me ?
Can you make a simple program for any app from playstore with assert command in it?

Jitender Bhardwaj

Hi Jitender,

Unfortunately, I don’t have the time to do something like this. However, I really don’t need to as Amazon has already done this for you:

This is their Sample App for testing with AWS. Uses TestNg, uses assertions, is generic–all the things you want.

Don’t understand the code? Here is their full write up on the matter:


Hello @wreed,
Thanks a lot buddy!!

Could you please give sample code for ruby?