Introduce to TestNG

Dahun Yoo·2022년 10월 3일
0

Introduce to TestNG

목록 보기
1/5
post-thumbnail

TestNG에 대해서 간략하게 소개하는 글을 써봅니다.


What is the 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, such as:

  • Annotations.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc...).
  • Test that your code is multithread safe.
  • Flexible test configuration.
  • Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc...).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for runtime and logging (no dependencies).
  • Dependent methods for application server testing.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc...

https://testng.org/doc/index.html

TestNG는 2004년에 만들어진 프레임워크로이며, JUnit에 영감을 받아 만들어졌다고합니다.
JUnit은 Unit Test에 특화되어있다면, TestNG는 좀 더 범용적인 테스트들에서도 쉽게 사용할 수 있게 고안되었다고 하네요.

Key Difference between TestNG and JUnit

guru99.com 의 포스트에 따르면, TestNG와 Junit의 차이점을 아래와 같이 소개하고 있습니다.

  • TestNG is a Java-based framework, while JUnit is an open-source Unit Testing Framework for JAVA.
  • Comparing TestNG Vs JUnit, TestNG annotations are easier to use and understand than JUnit.
  • TestNG allows us to create parallel tests, whereas JUnit does not support running parallel tests.
  • In TestNG, Test cases can be grouped together, while in JUnit, Grouping tests together is not possible.

테스트케이스의 그룹핑과, 동시에 벙렬적으로 테스트를 실행하는 점이, TestNG와 Junit의 다른점이라고 소개하고 있네요.

실제로 많은 외국의 Selenium 영상에서는 TestNG를 많이 사용하고 있는데, 이것은 Selenium의 Grid와 같이 사용할 수 있는 것이 TestNG이기 때문이 아닐까 싶습니다.

Selenium and TestNG

TestNG의 공식문서페이지를 가면, Selenium 페이지가 별도로 있습니다.

많은 예시들이 있는 것은 아니지만, 어떻게 하면 실행할 수 있는지, 특히 파라미터의 설명이 눈에 띄입니다.

https://testng.org/doc/selenium.html

guru99.com에서는 Selenium과 같이쓰면 좋은 이유에 대해 아래와 같이 설명하고 있습니다.

  • Generate the report in a proper format including a number of test cases runs, the number of test cases passed, the number of test cases failed, and the number of test cases skipped.
  • Multiple test cases can be grouped more easily by converting them into testng.xml file. In which you can make priorities which test case should be executed first.
  • The same test case can be executed multiple times without loops just by using keyword called ‘invocation count.’
  • Using testng, you can execute multiple test cases on multiple browsers, i.e., cross browser testing.
  • The TestNG framework can be easily integrated with tools like TestNG Maven, Jenkins, etc.
  • Annotations used in the testing are very easy to understand ex: @BeforeMethod, @AfterMethod, @BeforeTest, @AfterTest
  • WebDriver has no native mechanism for generating reports. TestNG can generate the report in a readable format like the one shown below.
  • TestNG simplifies the way the tests are coded. There is no more need for a static main method in our tests. The sequence of actions is regulated by easy-to-understand annotations that do not require methods to be static.
  • Uncaught exceptions are automatically handled by TestNG without terminating the test prematurely. These exceptions are reported as failed steps in the report.

앞으로 조금조금씩 기재해볼까합니다.

Ref

profile
QA Engineer

0개의 댓글