Пікірлер
@stephenlennon9299
@stephenlennon9299 4 күн бұрын
Superb teaching. Keep it up. Bravo!
@dehrk9024
@dehrk9024 7 күн бұрын
Thanks Aneesh
@rekhakumavat861
@rekhakumavat861 8 күн бұрын
Sir ji apka number dijiye
@chayanmukherjee16
@chayanmukherjee16 10 күн бұрын
Nice concise explanation!
@surbhiagarwal2322
@surbhiagarwal2322 12 күн бұрын
Isn't TSL what's used now? Built on top of SSL
@anak-i1z
@anak-i1z 13 күн бұрын
This video and this channel deserve atleast 3 zeros more in the amount of likes and subscribers...
@sasherazi
@sasherazi 19 күн бұрын
top quality content
@AneeshMistry
@AneeshMistry 16 күн бұрын
Thank you so much!
@akashg9863
@akashg9863 20 күн бұрын
Your have arranged the content very well. The definitions are easy with good examples. I haven't got a chance to use Spy in real world. Thanks for creating this. I will recommend this and the previous video as a starter for anyone who is new to Mockito.
@AneeshMistry
@AneeshMistry 16 күн бұрын
Thank you so much! It means a lot to me, I am glad it helped
@Leo-cw6dr
@Leo-cw6dr 26 күн бұрын
Thank you for the video! Looking forward to seeing more!!!
@AliN-s4f
@AliN-s4f Ай бұрын
This is such a great video
@AneeshMistry
@AneeshMistry 16 күн бұрын
Thank you!
@JamesBrown-lq5nn
@JamesBrown-lq5nn Ай бұрын
Direct, simple and on the money, love it!!
@beninip
@beninip Ай бұрын
I was struggling with that concept for months. I couldn't grasp it, luckily I came across this video. Now, it's clear than ever, clear and simple explaination. Good job!
@hftconsultancy
@hftconsultancy Ай бұрын
Please do continue
@AA-em3lw
@AA-em3lw Ай бұрын
great job (= Thank you for this short and practical video!
@1More_Dreamer
@1More_Dreamer 2 ай бұрын
Bro just expanded my intelect 😅
@Luizanbrg
@Luizanbrg 2 ай бұрын
thank you so much! your voice is super smooth and the explanation is very clear
@user-fl3of4pv7s
@user-fl3of4pv7s 2 ай бұрын
Excellent and simple explanation. Many thanks. You have great future ahead.
@rastemmilengephirchltechlte
@rastemmilengephirchltechlte 2 ай бұрын
One video for rest api with external api testing
@zahirulislam2097
@zahirulislam2097 3 ай бұрын
It was easy to follow. Thank you. Very good video on this topic.
@saveUyghurs
@saveUyghurs 3 ай бұрын
Had to watch multiple times to understand
@Jim-gr5uy
@Jim-gr5uy 3 ай бұрын
This is great Aneesh thanks a lot, teeing has been driving me made so this has helped! Cheers
@AneeshMistry
@AneeshMistry 3 ай бұрын
Thank you!
@HimanshuKumar-ow7hw
@HimanshuKumar-ow7hw 3 ай бұрын
CHATGPT: Updated PlayerStatisticsTest Class (JUnit 5) import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; public class PlayerStatisticsTest { private Player playerPatrickUnderThirty; private PlayerStatistics statisticsOfPatrickUnderThirty; @BeforeEach public void setup() { playerPatrickUnderThirty = new Player("Patrick", 27); statisticsOfPatrickUnderThirty = new PlayerStatistics(playerPatrickUnderThirty, 3, 3); } @Test @DisplayName("Player names should be equal") public void playerNameEqual() { Player player2 = new Player("Patrick", 25); assertThat(player2).isEqualTo(playerPatrickUnderThirty); } @Test @DisplayName("Player names should not be equal") public void playerNamesNotEqual() { Player player2 = new Player("Kalvin", 25); assertThat(player2).isNotEqualTo(playerPatrickUnderThirty); } @Test @DisplayName("Get the younger player when ages are different") public void youngerPlayerSame() { Player player2 = new Player("Patrick", 250); assertThat(PlayerStatistics.getYoungerPlayer(playerPatrickUnderThirty, player2)).isSameAs(playerPatrickUnderThirty); } @Test @DisplayName("Check if player is under thirty") public void underThirtyTrue() { assertThat(statisticsOfPatrickUnderThirty.underThirty()).isTrue(); } @Test @DisplayName("Check if player is not under thirty") public void underThirtyFalse() { Player player1 = new Player("Patrick", 37); PlayerStatistics statistics = new PlayerStatistics(player1, 3, 3); assertThat(statistics.underThirty()).isFalse(); } @Test @DisplayName("CSV Report should return null when games are zero") public void csvReportNull() { PlayerStatistics statistics = new PlayerStatistics(playerPatrickUnderThirty, 0, 0); assertThat(statistics.createCsvRecord()).isNull(); } @Test @DisplayName("CSV Report should not be null when games are greater than zero") public void csvReportNotNull() { PlayerStatistics statistics = new PlayerStatistics(playerPatrickUnderThirty, 3, 3); assertThat(statistics.createCsvRecord()).isNotNull(); } @Test @DisplayName("Get correct CSV stats record") public void getCsvStatsRecord() { PlayerStatistics statistics = new PlayerStatistics(playerPatrickUnderThirty, 4, 8); Double[] expectedArray = {2d, 0.5}; assertThat(statistics.createCsvRecord()).isEqualTo(expectedArray); } @Test @DisplayName("PlayerStatistics constructor should throw exception for null player") public void playerStatisticsConstructorThrowsExceptionForNullPlayer() { assertThrows(IllegalArgumentException.class, () -> { new PlayerStatistics(null, 3, 2); }); } @Test @DisplayName("PlayerStatistics constructor should throw exception for negative games") public void playerStatisticsConstructorThrowsExceptionForNegativeGames() { Player player = new Player("Patrick", 27); assertThrows(IllegalArgumentException.class, () -> { new PlayerStatistics(player, -1, 2); }); } @Test @DisplayName("PlayerStatistics constructor should throw exception for negative goals") public void playerStatisticsConstructorThrowsExceptionForNegativeGoals() { Player player = new Player("Patrick", 27); assertThrows(IllegalArgumentException.class, () -> { new PlayerStatistics(player, 3, -1); }); } } The @DisplayName annotation in JUnit 5 is used to specify a custom name or description for a test method. This custom name is displayed when the test results are reported, making it easier to understand the purpose of each test at a glance. Example Usage Here’s a quick example of how you might use @DisplayName: --------------------------------------------------------------------------------------------------------------- import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; public class ExampleTest { @Test @DisplayName("Should return true when the input is valid") void testValidInput() { // test code here } @Test @DisplayName("Should throw an exception for invalid input") void testInvalidInput() { // test code here } } Output When running these tests, the output will show the display names instead of just the method names, which provides clearer context on what each test is meant to verify: - Should return true when the input is valid Should throw an exception for invalid input -
@HimanshuKumar-ow7hw
@HimanshuKumar-ow7hw 3 ай бұрын
CHATGPT: RaceReportProcessorTest class converted to JUnit 5: import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static com.googlecode.catchexception.CatchException.catchException; import java.io.FileNotFoundException; public class RaceReportProcessorTest { private RaceReportProcessor reportProcessor; @BeforeEach public void setUp() { reportProcessor = new RaceReportProcessor(); } @AfterEach public void tearDown() { // Clean up temp files if created } @Test public void generateReportDriverFileThrowsFileNotFound() throws Exception { String driverFile = "drivers/drivers.csv"; String raceFile = "racePerformance/race.csv"; catchException(reportProcessor).generateReport(driverFile, raceFile); assertTrue(caughtException() instanceof FileNotFoundException); assertEquals("drivers/drivers.csv (No such file or directory)", caughtException().getMessage()); } @Test public void generateReportRaceFileThrowsFileNotFound() throws Exception { String driverFile = "drivers/drivers.csv"; // Assuming this file exists String raceFile = "racePerformance/race.csv"; // This file doesn't exist catchException(reportProcessor).generateReport(driverFile, raceFile); assertTrue(caughtException() instanceof FileNotFoundException); assertEquals("racePerformance/race.csv (No such file or directory)", caughtException().getMessage()); } @Test public void generateReportWithValidFiles() throws Exception { String driverFile = createTempDriverFile(); String raceFile = createTempRaceFile(); // Call the method and verify it runs without exceptions reportProcessor.generateReport(driverFile, raceFile); // Optionally verify the output } private String createTempDriverFile() { // Create and return the path of a temporary CSV file with driver data return "tempDriverFilePath"; // Replace with actual implementation } private String createTempRaceFile() { // Create and return the path of a temporary CSV file with race performance data return "tempRaceFilePath"; // Replace with actual implementation } } CatchException Library: If you're using the CatchException library, make sure it's compatible with JUnit 5. If you run into issues with it, consider using JUnit 5's Assertions.assertThrows() for exception testing.
@HimanshuKumar-ow7hw
@HimanshuKumar-ow7hw 3 ай бұрын
CHATGPT: Converted JUnit 5 Test Class: import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; public class CalculatorTest { @Test public void squaredIntegerHappyPath() { Calculator calculator = new Calculator(); assertEquals(9, calculator.squareInteger(3)); assertEquals(100, calculator.squareInteger(10)); } @Test public void squaredIntegerUpperBoundary() { Calculator calculator = new Calculator(); // Using assertThrows to check for IllegalArgumentException assertThrows(IllegalArgumentException.class, () -> calculator.squareInteger(50000)); } @Test public void squaredIntegerLowerBoundary() { Calculator calculator = new Calculator(); // Using assertThrows to check for IllegalArgumentException assertThrows(IllegalArgumentException.class, () -> calculator.squareInteger(-50000)); } @Test public void squaredIntegerNull() { Calculator calculator = new Calculator(); assertEquals(0, calculator.squareInteger(null)); } @Test public void squaredIntegerNegative() { Calculator calculator = new Calculator(); assertEquals(25, calculator.squareInteger(-5)); } @Test public void squaredIntegerNaN() { Calculator calculator = new Calculator(); // Using assertThrows to check for IllegalArgumentException assertThrows(IllegalArgumentException.class, () -> calculator.squareInteger((int) Math.sqrt(-5))); } }
@HimanshuKumar-ow7hw
@HimanshuKumar-ow7hw 3 ай бұрын
ChatGPT: JUnit 4 In JUnit 4, you can test for exceptions in two primary ways: Using @Test(expected = Exception.class): You can specify the expected exception using the expected attribute of the @Test annotation. java Copy code import org.junit.Test; public class MyTest { @Test(expected = IllegalArgumentException.class) public void testExceptionThrown() { // Code that should throw an exception int result = Integer.parseInt("invalid number"); } } In this example, if the code throws an IllegalArgumentException, the test will pass. Using try-catch with fail(): If you need more control over where the exception should be thrown (e.g., to verify the message), you can use a try-catch block along with fail(). java Copy code import org.junit.Test; import static org.junit.Assert.fail; public class MyTest { @Test public void testExceptionMessage() { try { int result = Integer.parseInt("invalid number"); fail("Exception not thrown!"); // Test will fail if this line is reached } catch (IllegalArgumentException e) { // Assert exception message assertEquals("For input string: \"invalid number\"", e.getMessage()); } } } JUnit 5 In JUnit 5, the approach is cleaner with the use of Assertions.assertThrows(). Using assertThrows(): This method allows you to specify the type of exception and the code that should throw it. java Copy code import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertThrows; public class MyTest { @Test public void testExceptionThrown() { // Expect an IllegalArgumentException assertThrows(IllegalArgumentException.class, () -> { Integer.parseInt("invalid number"); }); } } Checking the Exception Message: You can capture the thrown exception and assert specific details, like the message. java Copy code import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class MyTest { @Test public void testExceptionMessage() { IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> { Integer.parseInt("invalid number"); }); // Assert that the exception message matches the expected message assertEquals("For input string: \"invalid number\"", exception.getMessage()); } } Key Differences: In JUnit 4, you can use @Test(expected = Exception.class) but it doesn't allow you to verify exception messages or fine-tune where the exception is thrown. In JUnit 5, assertThrows() is a more flexible and modern approach, allowing you to check not only the type of the exception but also its message or any other behavior.
@yashwanthyerra2820
@yashwanthyerra2820 3 ай бұрын
does that mean doReturn() simplifies our work of mocking database/any such calls(i.e. we don't need to mock them as it is not interacting with that method) it simply provide us the response that we need to test the unit we need but not the dependencies
@skccharan
@skccharan 3 ай бұрын
Thanks
@fredericocostaguedespereir9240
@fredericocostaguedespereir9240 3 ай бұрын
Thank you so much, Aneesh!
@AneeshMistry
@AneeshMistry 3 ай бұрын
Glad it could help!
@ceriwestcott8784
@ceriwestcott8784 3 ай бұрын
Why use a class for DiaryEntry instead of interface?
@GopalRoy-nn6ft
@GopalRoy-nn6ft 3 ай бұрын
Autoscaling is not on ui in eks. Charges for contraol plane. Need to configure the autoscaling manually Nd metrics pods for autoscaling not default like othwr cloud kubernetes providers
@priyamghosh39
@priyamghosh39 3 ай бұрын
Hi, Thanks for you video. We are using below two annotations and @RepeatedTest is not compatible with them, any clue what other options we have to run a junit test multiple times? @MethodSource @ParameterizedTest()
@AneeshMistry
@AneeshMistry 3 ай бұрын
Hi, I would take a look at using RunWith Parameterized.class
@White_King
@White_King 4 ай бұрын
exactly what I was looking for, thank you!
@AneeshMistry
@AneeshMistry 3 ай бұрын
Thank you!
@lakshmirengaswamy9467
@lakshmirengaswamy9467 4 ай бұрын
Thank you sir...
@pirateg3cko
@pirateg3cko 4 ай бұрын
Great stuff, dude!
@cher-5484
@cher-5484 4 ай бұрын
That was clear, concise and very helpful. Thank you!
@djazzz_711
@djazzz_711 4 ай бұрын
incredibly easy video gg
@christhianlor
@christhianlor 4 ай бұрын
Hi, Aneesh! How Are You? Very nice explanation!
@chaitanyakulkarni-tm2jj
@chaitanyakulkarni-tm2jj 5 ай бұрын
Fantastic precious paid like content brother. May you get loads of subscribers and views.
@tiranworld7608
@tiranworld7608 5 ай бұрын
Why did u stop the Playlist please continue
@bunthaideng2492
@bunthaideng2492 5 ай бұрын
- AssertEquals 2:33 - AssertNotEquals 3:15 - AssertSame/NotSame 3:54 - AssertTrue 5:46 - AssertFalse 6:00 - AssertNull 7:28 - AssertArray 7:58
@abhis1083
@abhis1083 5 ай бұрын
thank you , good and clear explaination on junit mockito
@AneeshMistry
@AneeshMistry 5 ай бұрын
Glad it could help
@אסףלוטם-ק5צ
@אסףלוטם-ק5צ 5 ай бұрын
great video!
@AneeshMistry
@AneeshMistry 5 ай бұрын
Thank you
@robincannon2569
@robincannon2569 5 ай бұрын
I've been using angular for about the last 2 years. Mongodb has only just peaked my interest, but just got to say what a concise and straightforward angular tutorial you've presented. You clearly understand this framework very well. And thank you for the bhash suggestion i have to might replace my exisiting hashing method with that at some point. Good job :) thank you
@AneeshMistry
@AneeshMistry 5 ай бұрын
Thank you for your comment! I’m glad it could help you
@Vinayakgohel
@Vinayakgohel 6 ай бұрын
Will it execute method which is mocked?
@AneeshMistry
@AneeshMistry 6 ай бұрын
A mock won’t have the method executed. If you want the real method executed you can use a spy, which then allows you to mock other methods, or a real instance
@jonathanlevy8705
@jonathanlevy8705 6 ай бұрын
Thanks a ton, short and to the point.
@AneeshMistry
@AneeshMistry 6 ай бұрын
Thank you!
@ameyaghadigaonkar6630
@ameyaghadigaonkar6630 6 ай бұрын
Great content bro
@AneeshMistry
@AneeshMistry 6 ай бұрын
Thank you!
@HarshFactsAboutGirls
@HarshFactsAboutGirls 6 ай бұрын
fake accent of english makes video shit
@alighafari1011
@alighafari1011 6 ай бұрын
great thanks
@AneeshMistry
@AneeshMistry 6 ай бұрын
Thanks!
@jagadeeshp1163
@jagadeeshp1163 7 ай бұрын
YOUR ARE MY SAVIOUR BROTHER LOVE THIS PLAYLIST
@AneeshMistry
@AneeshMistry 6 ай бұрын
Thank you so much!!
@CullenKuch
@CullenKuch 7 ай бұрын
I am learning Angular and building a practice project. This series was exactly what I needed. Thank you so much! I got mine to work but now I just need to wrap my head around how its all actually working 😆
@AneeshMistry
@AneeshMistry 7 ай бұрын
Thank you! Try re-build the project component by component to build familiarity with Angular