I have a lot of classes extended from an abstract JUnit class that has several @Test cases. The thing is that in some of this extended classes i need to skip/ignore all the test cases only if one environment variable has a specific value.
For example, in ruby tests suites i can do the following in the before method:
require 'rubygems'
require 'minitest/spec'
require 'minitest/autorun'
require 'selenium-webdriver'
class WebPcAr < MiniTest::Test
    
    def setup
        
        ...
        
        ### SET URLS
        case ENV['ENVIRONMENT_NAME']
        when "test"
            skip
        when "preprod"
            skip
        when "prod"
            @base_url = 'http://www.google.com.ar/'
        else
            skip
        end
    end
Is there a way to do the same in Java? All i can find is the @Ignore way to do it, but as the @Tests that the class run are not in the same class, but in the abstract class, and those @Tests are shared among several other classes i cannot add the @Ignore tag to those @Test cases. Maybe with a @Rule that exists only in those specific extended classes that need it?
Remember that the @Tests are not in my class but an abstract one that is shared with other classes that don't need to skip/ignore them. And that I need to run all the classes in the same run, i can not pass class specific arguments to the maven command, because it need to be class specific.
Other way i found here Conditionally ignoring tests in JUnit 4 is to use the line "org.junit.Assume.assumeTrue(someCondition());" but i don't understand how to use it with my environment variable:
 @Before
 public void beforeMethod() {
     org.junit.Assume.assumeTrue(someCondition());
     // rest of setup.
 }
Maybe something like Ignore Test Cases Based on Environment? Did that not skip/ignore the test but gives me an "org.junit.AssumptionViolatedException: test" error
@Override
public void setUp() throws Exception {
    assumeTrue(System.getenv("AMBIENTE"), equals("prod"));
    super.setUp();
    ...
EDIT: This is my test class:
package My.Site.suitesWeb;
import static org.junit.Assert.assertTrue;
//import static org.junit.Assume.assumeTrue;
import org.junit.Ignore;
import org.junit.Test;
import My.Site.classesWeb.*;
public class TestWebPcMySite extends WebPcBase {
    @Override
    public void setUp() throws Exception {
        // Runs only in prod ENVIRONMENT
        String currentEnv = System.getenv("AMBIENTE");
        String expectedEnv = "prod";
        assumeTrue(currentEnv == expectedEnv );
        // Run parent class setup
        super.setUp();
        // Override with specific classes
        goTo = new ObjGoToPageWebPcMySite(driver);
        homePage = new ObjHomePageWebPcMySite(driver);
        loginPage = new ObjLoginPageWebPcMySite(driver);
    }
    // I IGNORE SOME METHODS FROM EXTENDED CLASS
    @Ignore
    @Test
    public void testHigh_LandingPage() throws Throwable {
    }
    @Ignore
    @Test
    public void testLow_LandingPage_LinkLogin() throws Throwable {
    }
    @Ignore
    @Test
    public void testLow_LandingPage_LinkRegister() throws Throwable {
    }
    // I OVERRIDE OTHER METHODS WITH OTHER CODE
    @Test
    public void testHigh_UserLogin_OkUserWithSuscriptionActive() throws Throwable {
        try {
            // Test data
            // Test case
            goTo.homePage(baseUrl);
            homePage.loginButton().click();
            loginPage.userLogin(usernameLogin, passwordLogin);
            assertTrue(homePage.profileNameButton().isDisplayed());
        } catch (Throwable e) {
            utilsCommon.errorHandle(e, suiteName, testName);
            throw e;
        }
    }
}
 
     
    