Skip to main content
10 votes
Accepted

What is the difference between jUnit & TestNG?

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use. TestNG is designed to cover all categories of tests:...
Bharat Mane's user avatar
  • 6,775
10 votes
Accepted

How to test if my application method handles HTTP status 404 of a REST API without actually calling that REST API

Use a mock. Mock 3rd party API using MockServer or WireMock, if you're in the Java world. Your test will call getNumUsers() method which in turn will call mock of your 3rd API and the mock will ...
dzieciou's user avatar
  • 10.5k
7 votes

How to reduce the time of our regression tests - interview question

Starting from your first question: Your answer did not give the interviewers any indication that you understand the technology challenges behind your automation suite. They were expecting answers ...
Kate Paulk's user avatar
  • 31.5k
6 votes

How to test if my application method handles HTTP status 404 of a REST API without actually calling that REST API

You don't need to add any additional dependency. Start doing some preparatory refactoring in order to: Program to an interface instead of a concrete object; Break the getNumUsers() into two ...
João Farias's user avatar
  • 10.9k
5 votes

How to reduce the time of our regression tests - interview question

How do you reduce the time of your regression suite? This may depend on what technologies the regression suite is based on. There can be technology/tool specific optimizations, like using faster ...
alecxe's user avatar
  • 11.4k
4 votes

JUnit Assert's message equivalent implementation using Selenium Webdriver's wait method

As it seems to me, the most close equivalent to JUnit assertion messages is withMessage() method introduced in FluentWait class. Below is the example of how I use it: public class Test { public ...
Alexey R.'s user avatar
  • 11.6k
4 votes
Accepted

How to write unit test for methods with a large number of parameters?

If refactoring is not an option then try to see this big function as a class of methods and focus on individual parts of this function which themselves are a logical entity, and design parameters ...
Vishal Aggarwal's user avatar
4 votes

what is difference between selenium web driver and junit?

Selenium is a tool that remote-controls a browser, You can use it to simulate a user interacting with a web site. for more info go through Selenium JUnit is a unit testing framework for writing Java ...
Meet's user avatar
  • 150
4 votes
Accepted

what is difference between selenium web driver and junit?

Selenium WebDriver is a tool using which we can automate any web application. It can open a browser, launch a URL, write on a text box, click buttons, etc. In short, it can simulate user actions. But ...
Kuldeep Rana's user avatar
3 votes

Unable to locate element as ID changes after refreshing the in Ebay login page

If 'ID' of your webElement changes everytime after refreshing the page in this situation: First of all look for any other attribute which Is not changing every time In that div node like name, class ...
Bharat Mane's user avatar
  • 6,775
3 votes

How to write unit test for methods with a large number of parameters?

I can't think of a developer writing a method which takes 25 arguments. This is a terrible design. Practically your method should not take more than 3 arguments. OK, coming to a solution, in case ...
Kshetra Mohan Prusty's user avatar
3 votes

How to write unit test for methods with a large number of parameters?

A good approach would be to use a test Facade for each feature you need to test, this would provide a public API for the testing of that feature only, but supports and hides the full width of the ...
Martin Spamer's user avatar
3 votes

How to provide Product Owner with estimates for unit testing?

I would argue that the question will not give any meaningful information and that you should make a stand if you are questioned in your practices as a professional. I will start by the question ...
João Farias's user avatar
  • 10.9k
3 votes
Accepted

Best strategy to test automatically a web application

There will always be some overlap in different tests, but if you look at the test pyramid the different layers have different goals. The test pyramid is a way of thinking about different kinds of ...
Niels van Reijmersdal's user avatar
3 votes

Automation solution for PDF content validation using Java

First of all, you mentioned a few different tags like Python and Java. You need to make it clear what language you want to use. I'd suggest using a language that you already know and/or your ...
pavelsaman's user avatar
  • 4,548
2 votes

Is throwing custom exceptions by test an anti-pattern?

Ideally I wrap the test step in a error handling mechanism that either throws the error and kills the test or it proceeds to the next step even if it fails. The test log records the failure, but the ...
mutt's user avatar
  • 1,693
2 votes
Accepted

How to skip test cases in a JUnit testsuite?

1. You need to import import org.junit.Ignore; 2. Tag @Ignore is available in JUnit - It will skip your test from executing @Ignore @Test public void your_test_to_skipped() { ---; ---; }
Narendra Chandratre's user avatar
2 votes
Accepted

Attaching screenshots to JUnit test reports

I haven't tried it but I remember seeing it in a YouTube video I watched years ago. Kohsuke Kawaguchi's talk Jenkins Selenium Meetup: Kohsuke Kawaguchi on how Jenkins + Selenium = Love at around the ...
kirbycope's user avatar
  • 4,090
2 votes

Using Jtidy to parsing HTML

I had the same question/problem. This is how I solved it: String validHtml = "some valid html"; InputStream inputStream = new ByteArrayInputStream(validHtml.getBytes(StandardCharsets.UTF_8)); Tidy ...
AntonioOtero's user avatar
2 votes
Accepted

Uncertain as how to test complex method

The first thing to consider is that you're going to need multiple tests to cover this unit. Here's how I'd approach it: Each defined condition gets a test: so there'll be a test method for ...
Kate Paulk's user avatar
  • 31.5k
2 votes

How to reduce Phantom js test execution time for selenium junit test cases

PhantomJS was abandoned, author recommends to switch to headless Chrome. Parallelization proposed by dzieciou might help, but you will be spending time to improve wrong tool.
Peter M. - stands for Monica's user avatar
2 votes

How to reduce Phantom js test execution time for selenium junit test cases

There are multiple solutions: Use faster locators like id and name. See What makes a good selenium locator? Run your tests in parallel Change part of your tests to REST API tests, component and unit ...
dzieciou's user avatar
  • 10.5k
2 votes
Accepted

Unable to locate element as ID changes after refreshing the in Ebay login page

The following XPath should work: //input[@placeholder='Email or username'][@type='text']
NotInventedHere's user avatar
2 votes

What is the difference between jUnit & TestNG?

Major difference in TestNG and JUnit test frameworks is their scope. I suggest to use TestNG as core unit test framework for Java project, because TestNG is more advance in parameterize testing, ...
Ravi Ojha's user avatar
  • 395
2 votes

How to write unit test for methods with a large number of parameters?

I guess most of the parameters can have some default value. You can always write a wrapper in your test code for the method that takes a parameter object and calls the original method. The parameter ...
Dakshinamurthy Karra's user avatar
2 votes
Accepted

Katalon or Java+Junit+Cucumber to automate tests?

Katalon is a software which can automate your test. You have to create script (or use the macro builder) to execute your test Cucumber is a software which use the gherkin language. It's not a tool ...
Jérémie Valentin's user avatar
2 votes

Katalon or Java+Junit+Cucumber to automate tests?

You can now use Cucumber inside Katalon Studio. If you don't like its generated code you can write all the scripts yourself - Katalon doesn't prevent you from doing so. This tool will save you a lot ...
Hai Minh Nguyen's user avatar
2 votes

How to provide Product Owner with estimates for unit testing?

As with application code, attempting time estimation at a low level such as hours, days or weeks is not only an exercise in frustration (and much wasted effort) but will inevitably lead to (as we have ...
Michael Durrant's user avatar
2 votes

Can I use this library for Junit?

I think you are confusing somethings. You are using a programming language called Java. You are using a testrunner library called JUnit, which is a Java Package called org.junit org.apache.commons.io....
Niels van Reijmersdal's user avatar
2 votes

java.lang.NullPointerException problem in Selenium Test

Try to change @FindBy(xpath = "a[@class='HeaderMenu-link no-underline mr-3']") private WebElement signInBtn; to @FindBy(xpath = "//a[@class='HeaderMenu-link no-underline mr-3']") private ...
Gryu's user avatar
  • 181

Only top scored, non community-wiki answers of a minimum length are eligible