JUnit 5 Tutorial by Hyder Abbas

Поделиться
HTML-код
  • Опубликовано: 1 июн 2024
  • JUnit is an open-source unit testing framework for the Java programming language. It is one of the most popular frameworks used for writing and running repeatable tests in Java. JUnit has been important in the development of test-driven development.
    00:00:00 - Introduction
    00:01:49 - Testing and Unit testing
    00:09:22 - Need of Junit 5 (Testing Framework)
    00:19:31 - Maven project for Junit
    00:29:22 - Running First Junit Test
    00:33:35 - Junit Test without Maven
    00:40:14 - Writing Test with JUnit5 without Maven
    00:46:33 - @Test Annotation
    00:51:38 - Assertions
    00:55:11 - Write Test then Code
    01:06:49 - JUnit5 Maven project setup
    01:16:14 - surefire plugin integration for maven project
    01:20:40 - More on assertEquals() method
    01:25:46 - Assertion over an array
    01:32:29 - Testing Exception with try-catch and assertThrows() method
    01:44:58 - Testing performance with assertTimeout() and timeout attribute
    01:51:16 - @BeforeEach and @AfterEach
    02:00:46 - @BeforeAll and @AfterAll
    02:06:30 - TestInstance Behavior
    #junit #testing
    Telusko Courses:
    Spring and Microservices Live Course : bit.ly/springmslive
    Coupon: TELUSKO25 (25% Discount)
    Industry-Ready Java Spring Microservices Developer Live : bit.ly/JavaMS2
    Complete Java Developer Course : bit.ly/Comp-Java-Dev-2
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Java:- bit.ly/JavaUdemyTelusko
    Spring:- bit.ly/SpringUdemyTelusko
    Java For Programmers:- bit.ly/javaProgrammers
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusko.com/
    Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    TELUSKO Android App : bit.ly/TeluskoApp
    TELUSKO IOS App : apple.co/3SsgmU2
    Discord : / discord
  • НаукаНаука

Комментарии • 31

  • @aparnagarlapati3480
    @aparnagarlapati3480 6 месяцев назад +14

    Hyder sir is one of the best instructors I have ever known

  • @towrukhan
    @towrukhan 6 месяцев назад +9

    Hyder sir is an exceptional mentor and leader. His dedication to his teaching to the success of his students are truly inspiring.

  • @martindzeble
    @martindzeble 6 месяцев назад +6

    I don't think I should watch till end before liking this video, 15 seconds is enough for me to smash the like button.
    Because the guy I see on screen will never teach trash, his explanation is invincible, judging from his previous videos on
    this channel. In fact he's a god of software engineering.
    If RUclips will allow me to like more than 1, I would have like infinity times. Telusko, you're best in programming, that's why you always come with the best. Long live TELUSKO, long live HYDER ABBAS

  • @msk9182
    @msk9182 6 месяцев назад +11

    Hyder abbas sir fans like button 👍

  • @Wisdomizer
    @Wisdomizer 6 месяцев назад +3

    Good explanation need best understanding, 1000 likes for Hyder sir 🎉.

  • @addytechie6948
    @addytechie6948 4 месяца назад +3

    🎯 Key Takeaways for quick navigation:
    00:00 🎯 *Introduction to JUnit 5 Testing Framework by Hyder Abbas.*
    02:47 🔄 *Unit Testing vs. Traditional Testing: Unit testing is done by the developer while writing the code, focusing on individual units (methods/classes), contrasting with traditional testing done post-development by a dedicated testing team.*
    06:35 🧪 *Manual Unit Testing: Demonstrates manual unit testing steps without a testing framework, involving method invocation, input preparation, result verification, and developer alerting.*
    18:03 🛠️ *Benefits of JUnit 5: Introduction to JUnit 5 framework, highlighting its role in simplifying unit testing by handling test preparation, execution, assertion, and developer alerting.*
    20:23 🚀 *Setting Up Maven Project in Eclipse: Step-by-step guide on creating a Maven project in Eclipse for JUnit testing, emphasizing the importance of project structure and dependency management.*
    25:24 🧪 *Explains the process of writing JUnit tests for Java applications, emphasizing the importance of testing units in isolation.*
    26:47 📝 *Demonstrates how to manually create JUnit tests in Eclipse, including specifying the class under test, package, and naming conventions.*
    28:25 🛠️ *Shows an alternative method in Eclipse to generate JUnit test cases automatically, streamlining the test creation process.*
    31:43 ✔️ *Illustrates how to use the `assertEquals` method to compare expected and actual results in a JUnit test, verifying the correctness of a method.*
    33:49 🏗️ *Introduces creating JUnit tests in a simple Java project without Maven, emphasizing the separation of test and application code.*
    40:18 🚀 *Demonstrates writing JUnit 5 (Jupiter) tests in a simple Java project, highlighting the use of the `@Test` annotation and flexibility in method access modifiers.*
    49:14 🟢 *Explains that JUnit considers a test successful by default if it doesn't fail, indicating the default behavior in JUnit testing.*
    51:43 🧪 *Assertion in JUnit is about comparing expected results with actual results, checking if your code meets expectations.*
    52:54 🟢 *If the expectation matches reality, JUnit displays a green bar, indicating a passed test; otherwise, it shows a red bar for a failed test.*
    53:35 🛡️ *JUnit 5, or JUnit Jupiter, provides assertion methods in the `org.junit.jupiter.api.Assertions` class for verifying expectation versus reality.*
    54:39 🧰 *JUnit Jupiter supports Java 8 features like Lambda expressions and the Stream API, offering more flexibility in testing.*
    55:23 🏗️ *Test-Driven Development (TDD) methodology involves writing tests before code, failing the tests, and then implementing the code to make the tests pass.*
    58:03 🚀 *Demonstrates TDD by creating a simple Java project in Eclipse, writing a test for a method, letting it fail, and then implementing the method to make the test pass.*
    01:06:34 📦 *Shows how to create a Maven project for JUnit 5, adding dependencies and plugins in the `pom.xml` file.*
    01:13:13 🧪 *Writing a JUnit 5 test within a Maven project to test a method (`computeSquareArea`) in a class (`Shapes`).*
    01:16:11 🧰 *Hyder demonstrates running JUnit tests in Eclipse, highlighting its integrated test runners.*
    01:17:36 🚀 *Integration of Surefire plugin in Maven allows running tests independently of Eclipse, important for CI/CD processes.*
    01:19:37 🛠️ *Adding Surefire plugin in Maven enables running tests without Eclipse, enhancing project flexibility.*
    01:20:50 📝 *Understanding the `assertEquals` method for assertions, and the importance of using `Supplier` for more efficient message handling.*
    01:26:04 🔄 *Demonstrating the use of `assertArrayEquals` to perform assertions on arrays, checking for order, elements, and length.*
    01:32:22 ❌ *Testing exceptions using try-catch blocks in JUnit, ensuring that specific exceptions are generated by the tested code.*
    01:39:23 🧪 *When testing exceptions in JUnit, explicit test failure can be done by failing after the exception-generating statement but before the catch block. This ensures the catch block won't execute if an exception occurs, indicating a passing test.*
    01:42:07 🧪 *JUnit 5 introduces the `assertThrows` method for testing exceptions. It allows specifying the expected exception type and the executable to test, enhancing exception testing.*
    01:45:05 🕰️ *To test the performance of a unit, JUnit 5 provides the `assertTimeout` method. It allows setting a time limit for a unit to complete execution, ensuring it performs within the specified duration.*
    01:51:14 🔄 *The order of execution in a JUnit class involves static initialization, static methods (if any), object creation, non-static methods (tests), and object destruction. Understanding this order helps when using setup and cleanup methods.*
    01:52:36 🌐 *JUnit 5 provides annotations `@BeforeEach` and `@AfterEach` to mark methods that should run before and after each test method, respectively. This is useful for common setup and cleanup tasks.*
    02:00:47 🔄 *The `@BeforeAll` and `@AfterAll` annotations in JUnit 5 designate methods that run once before and after all test methods, respectively. These are typically used for setup and cleanup that is common to all tests in a class.*
    02:03:22 🌐 *The `@BeforeAll` annotation in JUnit 5 is used for methods that need to be executed once before all test cases.*
    02:04:19 🔄 *Similarly, the `@AfterAll` annotation is used for methods that need to be executed once after all test cases.*
    02:06:34 ⚡️ *Methods annotated with `@BeforeAll` and `@AfterAll` should be static and are independent of class instances.*
    02:09:06 🔄 *To control the instance creation behavior in JUnit 5, use `@TestInstance` annotation with `LifeCycle.PER_CLASS` to create a single instance for all test methods in a class.*
    Made with HARPA AI

  • @vikaskumargupta1173
    @vikaskumargupta1173 6 месяцев назад +2

    Hyder sir your teaching is fav highly appreciable 🙏

  • @ilyasbakhtiar5465
    @ilyasbakhtiar5465 6 месяцев назад +1

    Nice to see Hyder Abbas speak on Telusko. Already I was a fan of Naveen Reddy

  • @satishp351
    @satishp351 6 месяцев назад +1

    Love the video ,waiting for more videos .

  • @Grow_Mindset
    @Grow_Mindset 6 месяцев назад +2

    Amazing lecture sir😇

  • @Asingh42
    @Asingh42 6 месяцев назад +2

    Great session 🤩

  • @Heartless-he8km
    @Heartless-he8km 6 месяцев назад

    Informative content.

  • @legendtony9098
    @legendtony9098 6 месяцев назад +1

    Thanks for the course

  • @abishasherlin5896
    @abishasherlin5896 6 месяцев назад +1

    Sir, please teach spring security in next session... And cloud..and so on...

  • @ahmedibrahim9901
    @ahmedibrahim9901 6 месяцев назад

    Please do unit testing using mockito, I'm struggling with that.

  • @prakhar_keshari
    @prakhar_keshari 3 месяца назад

    Excellent

  • @chinimillimanikanta1234
    @chinimillimanikanta1234 6 месяцев назад +1

    Please do unit testing using Mockito

  • @niitnahuja8793
    @niitnahuja8793 3 месяца назад

    Please guide me where are the properties of junit5 that are specified in your Junit 5 Maven project setup.

  • @milankbudha
    @milankbudha 6 месяцев назад +1

    thank you so much

  • @saitejakamineni-tt7vi
    @saitejakamineni-tt7vi 6 месяцев назад +1

    Pls teach spring security and oauth

  • @kartheekm2752
    @kartheekm2752 6 месяцев назад +1

    Also please add mockito and powermockito tutorial please

  • @IncusitiveSoul
    @IncusitiveSoul 2 месяца назад

    Where is the GitHub link for dependencies mentioned in the video..as discussed they are not in the description.

  • @Asingh42
    @Asingh42 6 месяцев назад

    We need mockito in depth also sir

  • @turtle421
    @turtle421 Месяц назад

    Bhai, sab kuch sahi tha, tabhi 1.06 par jo project create kiya hai, uski pom.xml file share kar dete toh achha rehta.

  • @ahmadwaheed8003
    @ahmadwaheed8003 6 месяцев назад

    Hyder sir ❤

  • @vallurunaveenreddy6038
    @vallurunaveenreddy6038 5 месяцев назад

    Please add nitin sir also in upcoming videos

  • @bozotrades
    @bozotrades 6 месяцев назад +1

    I like the way he saying rrrrrrun... Just kidding. Awesome explanation

  • @ziyaulbeg
    @ziyaulbeg 7 часов назад

    Properties file kha hain

  • @RishiRajxtrim
    @RishiRajxtrim 6 месяцев назад

    👍

  • @kakashi-69-xd
    @kakashi-69-xd 6 месяцев назад

    waiting for rust

  • @govindgupta290
    @govindgupta290 4 месяца назад +1

    TestNG is better