0

I've never used TestNG before so I'm trying to understand it. I've installed TestNG and Built the path. I made a TestNG class with tests. But upon running as TestNG I get the error: Cannot find class in classpath

I am aware there are multiple questions out there with this issue but I've tried the answers given and none have worked.

I have tried this using JUnit and it ran successfully. Now I'm just trying to redo it using TestNG.

Here is a screenshot of my project in Eclipse

public class TestSignInAndNotebook {

private WebDriver driver;
private Login login;
private Home home;
private CloudApp cloudApp;
private Notebook notebook;

@BeforeTest
public void beforeTest() {
    driver = new FirefoxDriver();
}

@Parameters({""})
@Test
public void f() {
    /* My test code */
}


@AfterTest
public void afterTest() {
    driver.quit();
}

}

If you need anymore information let me know.

5
  • Can you check from which folder the TestNG is starting. You can check this from your "Run Configuration" I believe . Commented Jul 21, 2016 at 18:06
  • How are you running your test case? Using TestNG suite file through Eclipse or running individually Commented Jul 21, 2016 at 18:34
  • @AlexanderPetrov - Under Run Configurations it shows that it's running in the project called Wolfram, which is the correct project. Is that what you were asking? Commented Jul 21, 2016 at 20:09
  • @KaarthickRamaMoorthy - I'm running using the TestNG suite through Eclipse. Commented Jul 21, 2016 at 20:10
  • @Alex - Have you tried running the class TestSignInAndNotebook individually? Was that working? Commented Jul 21, 2016 at 20:24

2 Answers 2

0

Can you try adding your folder Tests under the build path . Looks like it not added there and hence, is unable to recognise the class. It should be like Wolfram/Tests under your Source

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for pointing that out! I believe that the Tests folder is now under the Build Path (I could be wrong though). Unfortunately I'm still getting the error. I have updated my post and I have included my test class code and an update image of my project, if that helps.
0

Ah. I'm dumb. I had an annotation @Parameters({""}). But I didn't have anything in the quotes. I removed the annotation and it works like a charm. I have a feeling that all these answers also helped though. Thanks to all!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.