简体   繁体   中英

Strange behaviour of Android Studio at launching the JUnit test from the popup menu

I have a simple test, here is the start of it.

import org.junit.Before;
import org.junit.Test;
import org.junit.Assert;

public class BanknotesCountingTest {
    @Before
    public void setUp() {
        System.out.println("before test");
    }
.....

If I launch it from the toolbar of Android Studio, it runs OK, printing the "before test" line and later launching all tests. The debugging can be launched by the bug icon.

If I am right clicking on it in the Projects view and choose "run ..." in the popup menu , it shows the green OK button, with no tests in it. No output to console, no stop at any breakpoint works if I launch it as "debug ...", also from popup menu. It seems, the test file doesn't run really, but AS simulates the good results.

Obviously, these two ways of launching are different. But what is that difference?

Oh, sorry, I have found my error.

I have changed the test from a testNG one, and two Run configurations remained as the result. By right click the obsolete testNG configuration was launched (don't know why). And in the toolbar the JUnit configuration was chosen. And I launched it, clicking on the "Run" triangle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM