1

Is this a really good idea to use Unit Test Framework for End-To-End testing ? I'm thinking about method annotations to trigger test execution. Since we don't have a lot of control about the execution order and concurrence... Is this a common way to execute E2E tests ?

6 Answers 6

1

Is this a really good idea to use Unit Test Framework for End-To-End testing?

This question can be interpreted in multiple ways.

First, if you are asking "can we use the same tools for e2e testing as unit testing?" then yes you can.

For example, if you are using JavaScript, you can use Mocha/Chia, Jasmine, or Jest for both unit tests and e2e tests. While they are made initially for unit tests, they have been adopted for many testing use cases, including e2e tests. These tools allow you to use them as a test runner, test assertions, test tagging, etc. These libraries are well-documented and have continued support. If you don't use these tools in e2e tests, what are you going to use?

Not all unit test tools are created equal. For example, if using Ruby, I would not use rspec for e2e tests. Mainly due to a lack of documentation and any feature updates that would support e2e tests.

Second, what do you mean by "framework?" Often, people conflate "framework," "library," "tool name," etc. The tools listed above are libraries that you use in order to create a framework of tests and test suites. "Framework" here is more about how you architect your solution, organize it, and tool selections.

In the end, you can use the same tools for both unit and e2e tests -- your implementation will be different.

1

A little more detail would be helpful. What do you mean by end to end tests? Front end tests with Selenium maybe? Or API testing flows touching multiple endpoints and maybe a DB? What programming language are you using?
The short answer is YES, you can and should use a unit testing framework for end2end testing. I'm not sure how you could do it without one, as all IDEs I've worked with use some sort of unit test adapter to discover tests.

0

Yes, I've done exactly that everywhere I've worked for the past 15 years, in Java, C#, and Python. There are some shortcomings using an xUnit style framework for e2e (system) tests, but the pros outweigh the cons.

(I'm assuming here that "framework" in this case means something like TestNG, Unit, Pytest, etc.)

0

Using a unit test framework for end-to-end (E2E) testing can be a good idea in some cases, but it may not always be the best choice. Unit test frameworks are typically designed for testing individual units of code, rather than the integration of multiple units and systems. As such, they may not offer all of the features that are needed for E2E testing, such as the ability to handle asynchronous actions or simulate user interactions.

That being said, if you are already familiar with a unit test framework and it provides the necessary features for your E2E tests, it may be a convenient choice. Using method annotations to trigger test execution can also be a useful way to organize and run your tests. However, it is important to carefully consider whether a unit test framework is the best fit for your E2E testing needs before proceeding.

0

No, it is not a good idea to use a unit test framework for end-to-end (E2E) testing. Unit tests and E2E tests serve different purposes and have different goals.

Unit tests are typically focused on testing individual units of code in isolation, such as individual functions, methods, or classes. They are usually fast, reliable, and repeatable, and are used to validate that the code is working as intended and catching any regressions early in the development process. Unit tests are usually written and executed by developers, and they are tightly integrated into the development process and the codebase.

E2E tests, on the other hand, are focused on testing the complete system or application, end-to-end, simulating real-world user scenarios and validating the integration and functionality of the different components and systems. E2E tests are typically slower, more fragile, and more complex than unit tests, and are used to validate the quality, reliability, and usability of the system before release. E2E tests are usually written and executed by QA teams, and they are typically executed less frequently than unit tests, for example, before releases or deployments.

Unit test frameworks, such as JUnit, NUnit, or TestNG, are not well-suited for E2E testing, as they do not provide the necessary abstraction, flexibility, or support for testing a complete system end-to-end. Instead, it is recommended to use E2E testing frameworks, such as Cypress, Selenium, or Puppeteer, which are specifically designed and optimized for E2E testing.

To conclude, while unit tests and E2E tests both play important roles in software development, it is not recommended to use a unit test framework for E2E testing, as they have different goals and requirements.

-1

Unit tests :

  • Unit tests are intended to ensure code and methods are working as expected
  • Mostly developers implement unit tests

End to End testing :

  • E2E testing is something we are replicating exactly from start to end just like end user is going to perform in live or production environment
  • This is mostly carried out by QA members with positive and negative scenarios

Your question :

  • NO, we should not
  • Actually those two ways are definitely ensuring the quality somewhere but the objectives are different for both
  • Based on this understanding, we should not use Unit tests as E2E testing

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.