Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 417445

Summary: [JUnit] @RunWith(Parameterized) results don't navigate with JRE + JUnit 4.11
Product: [Eclipse Project] JDT Reporter: Rajiv Singh <rajivpaulsingh>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.8.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Rajiv Singh CLA 2013-09-17 12:43:05 EDT
Steps To Reproduce:
1. Compile and run the test below in with JRE7 + JUnit 4.11 + JDK1.7
2. Double-click on the failed test in the JUnit view

Expected result: Should open the testIsFirst() method

Actual result: "Method 'americanTest' not found"

Please note that I am calling the parameters from external excel sheet.
Below are the required details of the system I am using:

1). Version: Juno Service Release 2 Build id: 20130225-0426
2). JUnit 4.11 jar


Please note that the previous written parameterized scripts are running totally fine, but all the new scripts (copied from the old running scripts template) are giving this error.

Please help me.

Thank you so much in advance !
Rajiv

Just FYI....below is the code which is failing:

---------------------------------------------------------------------
package com.insurancebrokers.agentwebsite;

import java.io.IOException;
import java.util.List;
import java.util.Random;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.By;

import com.insurancebrokers.browsersetup.BaseSeleniumTest;
import com.insurancebrokers.dataaccess.AmericanDao;
import com.insurancebrokers.utility.QuoteAmerican;

@RunWith(JUnitParamsRunner.class)
public class AmericanTestRunner extends BaseSeleniumTest{

	static Logger logger = Logger.getLogger(AmericanTestRunner.class.getName());	
	
	@SuppressWarnings("unused")
	 private List<QuoteAmerican> parametersForAmericanTest() {
		List<QuoteAmerican> quoteAmericans = AmericanDao.getQuoteAmericans();
		logger.info("Number of Quote Americans is :" + quoteAmericans.size());
		 return quoteAmericans; 
	 }
	 
	 @Test
	 @Parameters
	 public void americanTest(QuoteAmerican quoteAmerican) throws InterruptedException, IOException {
		 
		QuoteTest quoteTest = new QuoteTest();
		quoteTest.quoteTest(quoteAmerican.getQuote());
						
		logger.info("americanTest");
		
		Random rand = new Random();
		 //get number of American offers and select one American offer randomly
		 int numberOfAmericanOffers = driver.findElements(By.cssSelector("a[data-action=american]")).size();
		 logger.info("No. of american offers rec'd : " + numberOfAmericanOffers);
		 driver.findElements(By.cssSelector("a[data-action=american]")).get(rand.nextInt(numberOfAmericanOffers)).click();
		
		AmericanStepOneTestCase stepOneTestCase = new AmericanStepOneTestCase();
		stepOneTestCase.americanStepOneTest(quoteAmerican.getAmerican());
		
		
	 }
}
----------------------------------------------------------------

In issue # , it was a mentioned some workaround. Could you please let me know if I can use that workaround, if Yes then where to update it?


Below is the workaround that I was talking about (https://bugs.eclipse.org/bugs/attachment.cgi?id=135142&action=diff)

private static String extractRealMethodName(String testMethodName) {
83			//workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=275308 :
84			for (int i= 0; i < testMethodName.length(); i++) {
85				if (!Character.isJavaIdentifierPart(testMethodName.charAt(i))) {
86					return testMethodName.substring(0, i);
87				}
88			}
89			return testMethodName;
90		}
Comment 1 Rajiv Singh CLA 2013-09-17 17:39:26 EDT
This issue is similar to Bug 417445
Comment 2 Rajiv Singh CLA 2013-09-17 17:41:02 EDT
my bad its Bug 275308.
Comment 3 Rajiv Singh CLA 2013-09-17 17:41:13 EDT
my bad its Bug 275308.
(In reply to Rajiv Singh from comment #1)
> This issue is similar to Bug 417445
Comment 4 Dani Megert CLA 2013-09-18 05:08:34 EDT
(In reply to Rajiv Singh from comment #0)
> Steps To Reproduce:
> 1. Compile and run the test below in with JRE7 + JUnit 4.11 + JDK1.7

I get many compile errors after that step, so, nothing will run here.

Please provide a test case that we can actually use to reproduce the problem. We can then reopen the bug.
Comment 5 Rajiv Singh CLA 2013-09-18 13:33:51 EDT
That's because you need to add various jar files. Since the size of the jar files is more, I cannot add it here. Thanks for the reply though.

(In reply to Dani Megert from comment #4)
> (In reply to Rajiv Singh from comment #0)
> > Steps To Reproduce:
> > 1. Compile and run the test below in with JRE7 + JUnit 4.11 + JDK1.7
> 
> I get many compile errors after that step, so, nothing will run here.
> 
> Please provide a test case that we can actually use to reproduce the
> problem. We can then reopen the bug.
Comment 6 Rajiv Singh CLA 2014-01-28 14:12:16 EST
This issue still exist, I am not sure if you guys really want to fix it. Thanks!