0

In the following code, the assert statement seems to be ignored:

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    runTest();
}

private void runTest() 
{
    int a = 0;
    int b = 1;
    Log.d("Test", "Start");     
    assert a == b : "assertion failed";
    Log.d("Test", "End");       
}
}

The output is simply:
04-30 12:48:51.078: D/Test(29964): Start
04-30 12:48:51.078: D/Test(29964): End

There is no "assertion failed" there.

What is wrong with the code?

Hello_World
  • 387
  • 3
  • 13

0 Answers0