{"id":37052,"date":"2025-12-26T20:40:52","date_gmt":"2025-12-26T17:40:52","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=37052"},"modified":"2025-12-26T20:40:52","modified_gmt":"2025-12-26T17:40:52","slug":"junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/","title":{"rendered":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi"},"content":{"rendered":"<p><body><\/p>\n<h2>JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi<\/h2>\n<h3>Giri\u015f: Yaz\u0131l\u0131m Kalitesinde Testin \u00d6nemi ve JUnit&#8217;in Rol\u00fc<\/h3>\n<p>Yaz\u0131l\u0131m geli\u015ftirme s\u00fcreci, kod yazmaktan \u00e7ok daha fazlas\u0131n\u0131 i\u00e7erir. G\u00fcvenilir, s\u00fcrd\u00fcr\u00fclebilir ve hatas\u0131z uygulamalar geli\u015ftirmek i\u00e7in <strong>test<\/strong> s\u00fcreci hayati bir rol oynar. Testler, yaz\u0131l\u0131m\u0131n beklenen \u015fekilde \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 do\u011frular, hatalar\u0131 erken a\u015famada tespit etmeye yard\u0131mc\u0131 olur ve refactoring (kod iyile\u015ftirme) yaparken g\u00fcven verir. Bu test t\u00fcrlerinden en temeli ve en yayg\u0131n olan\u0131 <strong>birim testleridir (unit tests)<\/strong>. Birim testleri, bir yaz\u0131l\u0131m\u0131n en k\u00fc\u00e7\u00fck ba\u011f\u0131ms\u0131z par\u00e7alar\u0131n\u0131 (metotlar, s\u0131n\u0131flar) izole bir \u015fekilde test etmeyi ama\u00e7lar.<\/p>\n<p>Java ekosisteminde birim testleri i\u00e7in en pop\u00fcler ve k\u00f6kl\u00fc \u00e7er\u00e7eve \u015f\u00fcphesiz <strong>JUnit<\/strong>&#8216;tir. JUnit, Java geli\u015ftiricilerine test senaryolar\u0131 yazmak, \u00e7al\u0131\u015ft\u0131rmak ve sonu\u00e7lar\u0131n\u0131 de\u011ferlendirmek i\u00e7in g\u00fc\u00e7l\u00fc bir yap\u0131 sunar. Y\u0131llar i\u00e7inde bir\u00e7ok evrim ge\u00e7iren JUnit, \u00f6zellikle <strong>JUnit 4<\/strong> ve <strong>JUnit 5<\/strong> s\u00fcr\u00fcmleriyle farkl\u0131 mimariler ve \u00f6zellikler sunar. Bu makale, her iki JUnit s\u00fcr\u00fcm\u00fcn\u00fcn de <strong>Maven<\/strong> ile nas\u0131l kurulaca\u011f\u0131n\u0131, yap\u0131land\u0131r\u0131laca\u011f\u0131n\u0131 ve kullan\u0131laca\u011f\u0131n\u0131 detayl\u0131 bir \u015fekilde ele alacakt\u0131r. Ayr\u0131ca, iki s\u00fcr\u00fcm aras\u0131ndaki temel farklara, en iyi uygulamalara ve s\u0131k kar\u015f\u0131la\u015f\u0131lan sorunlara da de\u011finece\u011fiz.<\/p>\n<h3>Maven ve Ba\u011f\u0131ml\u0131l\u0131k Y\u00f6netimi: Neden Maven?<\/h3>\n<p>Modern Java projelerinde <strong>Maven<\/strong>, proje y\u00f6netimi ve anlama arac\u0131 olarak merkezi bir rol oynar. Proje yap\u0131s\u0131n\u0131 standartla\u015ft\u0131rmas\u0131, ba\u011f\u0131ml\u0131l\u0131klar\u0131 kolayca y\u00f6netmesi ve tutarl\u0131 bir build s\u00fcreci sa\u011flamas\u0131 nedeniyle geli\u015ftiricilerin vazge\u00e7ilmezidir. \u00d6zellikle test ba\u011f\u0131ml\u0131l\u0131klar\u0131 ve test \u00e7al\u0131\u015ft\u0131rma mekanizmalar\u0131 i\u00e7in Maven, s\u00fcrecin otomatize edilmesinde kritik \u00f6neme sahiptir.<\/p>\n<p>Maven&#8217;\u0131n kalbi, projenin yap\u0131land\u0131rmas\u0131n\u0131 ve ba\u011f\u0131ml\u0131l\u0131klar\u0131n\u0131 tan\u0131mlayan <strong><code>pom.xml<\/code><\/strong> (Project Object Model) dosyas\u0131d\u0131r. Bu dosya sayesinde, projenin hangi k\u00fct\u00fcphanelere (JUnit gibi) ihtiya\u00e7 duydu\u011fu, bu k\u00fct\u00fcphanelerin hangi versiyonlar\u0131n\u0131n kullan\u0131laca\u011f\u0131 ve projenin nas\u0131l derlenece\u011fi, test edilece\u011fi ve paketlenece\u011fi gibi bilgiler merkezi bir yerden y\u00f6netilir. Test ba\u011f\u0131ml\u0131l\u0131klar\u0131n\u0131 <code>pom.xml<\/code>&#8216;e eklemek, projenin test a\u015famas\u0131nda do\u011fru k\u00fct\u00fcphanelere eri\u015fmesini sa\u011flar.<\/p>\n<h3>JUnit 4 ile Maven Kurulumu ve Kullan\u0131m\u0131<\/h3>\n<p>JUnit 4, uzun y\u0131llar boyunca Java birim testlerinin fiili standard\u0131 olmu\u015ftur. Basit ve anla\u015f\u0131l\u0131r anotasyonlar\u0131 sayesinde h\u0131zl\u0131ca test yazmaya olanak tan\u0131r.<\/p>\n<h4>JUnit 4&#8217;e Genel Bak\u0131\u015f<\/h4>\n<p>JUnit 4, test metotlar\u0131n\u0131 tan\u0131mlamak i\u00e7in <code>@Test<\/code> anotasyonunu kullan\u0131r. Test ya\u015fam d\u00f6ng\u00fcs\u00fcn\u00fc y\u00f6netmek i\u00e7in <code>@Before<\/code>, <code>@After<\/code>, <code>@BeforeClass<\/code> ve <code>@AfterClass<\/code> gibi anotasyonlar sunar. Testlerin do\u011fru \u00e7al\u0131\u015f\u0131p \u00e7al\u0131\u015fmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in <code>org.junit.Assert<\/code> s\u0131n\u0131f\u0131ndaki statik metotlar (\u00f6rne\u011fin, <code>assertEquals<\/code>, <code>assertTrue<\/code>, <code>assertNull<\/code>) kullan\u0131l\u0131r.<\/p>\n<h4>Maven Ba\u011f\u0131ml\u0131l\u0131klar\u0131 (Dependencies)<\/h4>\n<p>JUnit 4&#8217;\u00fc bir Maven projesine dahil etmek i\u00e7in <code>pom.xml<\/code> dosyas\u0131na a\u015fa\u011f\u0131daki ba\u011f\u0131ml\u0131l\u0131\u011f\u0131 eklemeniz yeterlidir:<\/p>\n<pre><code class=\"language-xml\"><dependencies>\n    <dependency>\n        <groupId>junit<\/groupId>\n        <artifactId>junit<\/artifactId>\n        <version>4.13.2<\/version> <!-- En son stabil s\u00fcr\u00fcm -->\n        <scope>test<\/scope>\n    <\/dependency>\n<\/dependencies><\/code><\/pre>\n<p>Burada dikkat edilmesi gereken \u00f6nemli bir nokta, <code><scope>test<\/scope><\/code> etiketidir. Bu etiket, JUnit k\u00fct\u00fcphanesinin yaln\u0131zca test derleme ve \u00e7al\u0131\u015ft\u0131rma a\u015famalar\u0131nda kullan\u0131laca\u011f\u0131n\u0131 belirtir. Bu sayede, uygulaman\u0131z\u0131n nihai da\u011f\u0131t\u0131m\u0131nda (\u00f6rne\u011fin, bir JAR veya WAR dosyas\u0131nda) JUnit ba\u011f\u0131ml\u0131l\u0131\u011f\u0131 yer almaz, bu da dosya boyutunu k\u00fc\u00e7\u00fclt\u00fcr ve gereksiz ba\u011f\u0131ml\u0131l\u0131klar\u0131 ortadan kald\u0131r\u0131r.<\/p>\n<h4>pom.xml Yap\u0131land\u0131rmas\u0131<\/h4>\n<p>Yukar\u0131daki ba\u011f\u0131ml\u0131l\u0131klar\u0131 ekledikten sonra, temel bir <code>pom.xml<\/code> dosyan\u0131z \u015fu \u015fekilde g\u00f6r\u00fcnebilir:<\/p>\n<pre><code class=\"language-xml\"><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\"\n         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0<\/modelVersion>\n\n    <groupId>com.example<\/groupId>\n    <artifactId>my-app<\/artifactId>\n    <version>1.0-SNAPSHOT<\/version>\n\n    <properties>\n        <maven.compiler.source>1.8<\/maven.compiler.source>\n        <maven.compiler.target>1.8<\/maven.compiler.target>\n        <project.build.sourceEncoding>UTF-8<\/project.build.sourceEncoding>\n    <\/properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>junit<\/groupId>\n            <artifactId>junit<\/artifactId>\n            <version>4.13.2<\/version>\n            <scope>test<\/scope>\n        <\/dependency>\n    <\/dependencies>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins<\/groupId>\n                <artifactId>maven-surefire-plugin<\/artifactId>\n                <version>2.22.2<\/version> <!-- JUnit 4 i\u00e7in genellikle bu versiyon yeterlidir -->\n            <\/plugin>\n        <\/plugins>\n    <\/build>\n\n<\/project><\/code><\/pre>\n<p><strong><code>maven-surefire-plugin<\/code><\/strong>, Maven&#8217;\u0131n testleri \u00e7al\u0131\u015ft\u0131rmak i\u00e7in kulland\u0131\u011f\u0131 ana eklentidir. JUnit 4 testlerini varsay\u0131lan olarak destekler ve herhangi bir \u00f6zel yap\u0131land\u0131rma gerektirmeden genellikle \u00e7al\u0131\u015f\u0131r.<\/p>\n<h4>JUnit 4 Test S\u0131n\u0131f\u0131 \u00d6rne\u011fi<\/h4>\n<p>\u015eimdi basit bir hesap makinesi s\u0131n\u0131f\u0131 ve bunun i\u00e7in bir JUnit 4 test s\u0131n\u0131f\u0131 olu\u015ftural\u0131m.<\/p>\n<p><strong><code>src\/main\/java\/com\/example\/Calculator.java<\/code>:<\/strong><\/p>\n<pre><code class=\"language-java\">package com.example;\n\npublic class Calculator {\n    public int add(int a, int b) {\n        return a + b;\n    }\n\n    public int subtract(int a, int b) {\n        return a - b;\n    }\n}<\/code><\/pre>\n<p><strong><code>src\/test\/java\/com\/example\/CalculatorTest.java<\/code>:<\/strong><\/p>\n<pre><code class=\"language-java\">package com.example;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport static org.junit.Assert.*;\n\npublic class CalculatorTest {\n\n    private Calculator calculator;\n\n    @Before\n    public void setUp() {\n        \/\/ Her test metodundan \u00f6nce \u00e7al\u0131\u015f\u0131r\n        calculator = new Calculator();\n        System.out.println(\"Test ba\u015flang\u0131c\u0131: setUp metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @After\n    public void tearDown() {\n        \/\/ Her test metodundan sonra \u00e7al\u0131\u015f\u0131r\n        calculator = null;\n        System.out.println(\"Test biti\u015fi: tearDown metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test\n    public void testAdd() {\n        \/\/ Toplama i\u015flemini test et\n        int result = calculator.add(5, 3);\n        assertEquals(\"5 + 3 = 8 olmal\u0131\", 8, result);\n        System.out.println(\"testAdd \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test\n    public void testSubtract() {\n        \/\/ \u00c7\u0131karma i\u015flemini test et\n        int result = calculator.subtract(10, 4);\n        assertEquals(\"10 - 4 = 6 olmal\u0131\", 6, result);\n        System.out.println(\"testSubtract \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test(expected = ArithmeticException.class)\n    public void testDivideByZero() {\n        \/\/ JUnit 4'te istisna test etme \u00f6rne\u011fi\n        \/\/ calculator.divide(10, 0); \/\/ Bu metot Calculator s\u0131n\u0131f\u0131nda yok, sadece \u00f6rnek ama\u00e7l\u0131\n    }\n}<\/code><\/pre>\n<p><code>@Before<\/code> ve <code>@After<\/code> anotasyonlar\u0131, her test metodu \u00e7al\u0131\u015ft\u0131r\u0131lmadan \u00f6nce ve sonra belirli kurulum\/temizleme i\u015flemlerini yapman\u0131z\u0131 sa\u011flar. <code>@Test<\/code> anotasyonu, bir metodun test metodu oldu\u011funu belirtir. <code>assertEquals<\/code> gibi metotlar ise beklenen ve ger\u00e7ek de\u011ferleri kar\u015f\u0131la\u015ft\u0131rarak testin ge\u00e7ip ge\u00e7medi\u011fini belirler.<\/p>\n<h4>Testleri \u00c7al\u0131\u015ft\u0131rma<\/h4>\n<p>Testleri Maven ile \u00e7al\u0131\u015ft\u0131rmak i\u00e7in projenizin k\u00f6k dizininde a\u015fa\u011f\u0131daki komutu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-bash\">mvn test<\/code><\/pre>\n<p>Bu komut, projenizi derler ve ard\u0131ndan <code>maven-surefire-plugin<\/code> kullanarak t\u00fcm testleri \u00e7al\u0131\u015ft\u0131r\u0131r. Test sonu\u00e7lar\u0131n\u0131 konsolda g\u00f6rebilir ve <code>target\/surefire-reports\/<\/code> dizininde detayl\u0131 XML ve TXT raporlar\u0131n\u0131 bulabilirsiniz.<\/p>\n<h3>JUnit 5 (Jupiter) ile Maven Kurulumu ve Kullan\u0131m\u0131<\/h3>\n<p>JUnit 5, JUnit&#8217;in yeniden tasarlanm\u0131\u015f ve mod\u00fcler bir versiyonudur. Java 8 ve sonraki s\u00fcr\u00fcmlerin \u00f6zelliklerinden tam olarak yararlan\u0131r ve daha esnek, g\u00fc\u00e7l\u00fc bir test \u00e7er\u00e7evesi sunar.<\/p>\n<h4>JUnit 5&#8217;in Mimarisi<\/h4>\n<p>JUnit 5, \u00fc\u00e7 ana mod\u00fclden olu\u015fur:<br \/>\n*   <strong>JUnit Platform:<\/strong> Test \u00e7er\u00e7evelerini JVM \u00fczerinde ba\u015flatmak i\u00e7in temel bir API sa\u011flar. IDE&#8217;ler, build ara\u00e7lar\u0131 ve di\u011fer test \u00e7al\u0131\u015ft\u0131rma ara\u00e7lar\u0131 i\u00e7in bir aray\u00fczd\u00fcr.<br \/>\n*   <strong>JUnit Jupiter:<\/strong> JUnit 5&#8217;teki yeni programlama ve uzant\u0131 modelidir. Geli\u015ftiricilerin testleri yazmak i\u00e7in kulland\u0131\u011f\u0131 anotasyonlar\u0131 (<code>@Test<\/code>, <code>@BeforeEach<\/code> vb.) ve API&#8217;leri i\u00e7erir.<br \/>\n*   <strong>JUnit Vintage:<\/strong> JUnit 3 ve JUnit 4 testlerini JUnit 5 Platformu \u00fczerinde \u00e7al\u0131\u015ft\u0131rmak i\u00e7in geriye d\u00f6n\u00fck uyumluluk sa\u011flar.<\/p>\n<h4>Maven Ba\u011f\u0131ml\u0131l\u0131klar\u0131 (Dependencies)<\/h4>\n<p>JUnit 5&#8217;i bir Maven projesine dahil etmek i\u00e7in <code>pom.xml<\/code> dosyas\u0131na a\u015fa\u011f\u0131daki ba\u011f\u0131ml\u0131l\u0131klar\u0131 eklemeniz gerekir:<\/p>\n<pre><code class=\"language-xml\"><dependencies>\n    <!-- JUnit Jupiter API ve Engine -->\n    <dependency>\n        <groupId>org.junit.jupiter<\/groupId>\n        <artifactId>junit-jupiter-api<\/artifactId>\n        <version>5.10.0<\/version> <!-- En son stabil s\u00fcr\u00fcm -->\n        <scope>test<\/scope>\n    <\/dependency>\n    <dependency>\n        <groupId>org.junit.jupiter<\/groupId>\n        <artifactId>junit-jupiter-engine<\/artifactId>\n        <version>5.10.0<\/version>\n        <scope>test<\/scope>\n    <\/dependency>\n\n    <!-- JUnit Platform Launcher (\u0130ste\u011fe ba\u011fl\u0131, IDE entegrasyonu i\u00e7in faydal\u0131) -->\n    <dependency>\n        <groupId>org.junit.platform<\/groupId>\n        <artifactId>junit-platform-launcher<\/artifactId>\n        <version>1.10.0<\/version>\n        <scope>test<\/scope>\n    <\/dependency>\n\n    <!-- JUnit Vintage Engine (JUnit 4 testlerini de \u00e7al\u0131\u015ft\u0131rmak istiyorsan\u0131z) -->\n    <dependency>\n        <groupId>org.junit.vintage<\/groupId>\n        <artifactId>junit-vintage-engine<\/artifactId>\n        <version>5.10.0<\/version>\n        <scope>test<\/scope>\n    <\/dependency>\n<\/dependencies><\/code><\/pre>\n<p>*   <strong><code>junit-jupiter-api<\/code><\/strong>: Testleri yazmak i\u00e7in gerekli API&#8217;leri ve anotasyonlar\u0131 sa\u011flar.<br \/>\n*   <strong><code>junit-jupiter-engine<\/code><\/strong>: Jupiter tabanl\u0131 testleri ke\u015ffetmek ve \u00e7al\u0131\u015ft\u0131rmak i\u00e7in bir test motorudur.<br \/>\n*   <strong><code>junit-platform-launcher<\/code><\/strong>: JUnit Platformu&#8217;nu ba\u015flatmak i\u00e7in kullan\u0131l\u0131r, genellikle IDE&#8217;ler ve build ara\u00e7lar\u0131 taraf\u0131ndan kullan\u0131l\u0131r.<br \/>\n*   <strong><code>junit-vintage-engine<\/code><\/strong>: E\u011fer projenizde hem JUnit 4 hem de JUnit 5 testleri varsa ve ikisini de JUnit 5 Platformu \u00fczerinden \u00e7al\u0131\u015ft\u0131rmak istiyorsan\u0131z bu ba\u011f\u0131ml\u0131l\u0131\u011f\u0131 eklemelisiniz.<\/p>\n<h4>pom.xml Yap\u0131land\u0131rmas\u0131<\/h4>\n<p>JUnit 5 ba\u011f\u0131ml\u0131l\u0131klar\u0131na ek olarak, <code>maven-surefire-plugin<\/code>&#8216;i JUnit 5 testlerini do\u011fru \u015fekilde tan\u0131yacak ve \u00e7al\u0131\u015ft\u0131racak \u015fekilde yap\u0131land\u0131rman\u0131z gerekir. Ayr\u0131ca, JUnit 5 Java 8 veya daha yeni bir s\u00fcr\u00fcm gerektirdi\u011finden, <code>maven-compiler-plugin<\/code>&#8216;i de do\u011fru \u015fekilde ayarlaman\u0131z \u00f6nemlidir.<\/p>\n<pre><code class=\"language-xml\"><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\"\n         xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n         xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0<\/modelVersion>\n\n    <groupId>com.example<\/groupId>\n    <artifactId>my-app-junit5<\/artifactId>\n    <version>1.0-SNAPSHOT<\/version>\n\n    <properties>\n        <maven.compiler.source>11<\/maven.compiler.source> <!-- Java 8 veya \u00fczeri -->\n        <maven.compiler.target>11<\/maven.compiler.target> <!-- Java 8 veya \u00fczeri -->\n        <project.build.sourceEncoding>UTF-8<\/project.build.sourceEncoding>\n        <junit.jupiter.version>5.10.0<\/junit.jupiter.version>\n        <maven.surefire.plugin.version>3.2.3<\/maven.surefire.plugin.version> <!-- JUnit 5 deste\u011fi i\u00e7in yeni versiyon -->\n    <\/properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>org.junit.jupiter<\/groupId>\n            <artifactId>junit-jupiter-api<\/artifactId>\n            <version>${junit.jupiter.version}<\/version>\n            <scope>test<\/scope>\n        <\/dependency>\n        <dependency>\n            <groupId>org.junit.jupiter<\/groupId>\n            <artifactId>junit-jupiter-engine<\/artifactId>\n            <version>${junit.jupiter.version}<\/version>\n            <scope>test<\/scope>\n        <\/dependency>\n        <dependency>\n            <groupId>org.junit.platform<\/groupId>\n            <artifactId>junit-platform-launcher<\/artifactId>\n            <version>1.10.0<\/version>\n            <scope>test<\/scope>\n        <\/dependency>\n        <!-- JUnit 4 testlerini de \u00e7al\u0131\u015ft\u0131rmak isterseniz -->\n        <!--\n        <dependency>\n            <groupId>org.junit.vintage<\/groupId>\n            <artifactId>junit-vintage-engine<\/artifactId>\n            <version>${junit.jupiter.version}<\/version>\n            <scope>test<\/scope>\n        <\/dependency>\n        -->\n    <\/dependencies>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins<\/groupId>\n                <artifactId>maven-compiler-plugin<\/artifactId>\n                <version>3.11.0<\/version>\n                <configuration>\n                    <source>${maven.compiler.source}<\/source>\n                    <target>${maven.compiler.target}<\/target>\n                <\/configuration>\n            <\/plugin>\n            <plugin>\n                <groupId>org.apache.maven.plugins<\/groupId>\n                <artifactId>maven-surefire-plugin<\/artifactId>\n                <version>${maven.surefire.plugin.version}<\/version>\n                <!-- JUnit 5 testlerini \u00e7al\u0131\u015ft\u0131rmak i\u00e7in engine'leri yap\u0131land\u0131r -->\n                <configuration>\n                    <argLine>-Djunit.platform.unique-id-selectors=\"[engine:junit-jupiter]\"<\/argLine>\n                <\/configuration>\n            <\/plugin>\n        <\/plugins>\n    <\/build>\n\n<\/project><\/code><\/pre>\n<p><strong><code>maven-surefire-plugin<\/code><\/strong>&#8216;in <code>version<\/code> etiketinin 2.22.0 veya daha yeni bir s\u00fcr\u00fcm oldu\u011fundan emin olun, \u00e7\u00fcnk\u00fc JUnit 5 deste\u011fi bu s\u00fcr\u00fcmlerle gelmi\u015ftir. <code>argLine<\/code> yap\u0131land\u0131rmas\u0131, Surefire&#8217;\u0131n hangi JUnit motorlar\u0131n\u0131 kullanaca\u011f\u0131n\u0131 a\u00e7\u0131k\u00e7a belirtmek i\u00e7in kullan\u0131labilir, ancak genellikle bu yap\u0131land\u0131rma olmadan da Jupiter testleri do\u011fru \u015fekilde ke\u015ffedilir.<\/p>\n<h4>JUnit 5 Test S\u0131n\u0131f\u0131 \u00d6rne\u011fi<\/h4>\n<p>Hesap makinesi \u00f6rne\u011fimizi JUnit 5 ile yeniden yazal\u0131m.<\/p>\n<p><strong><code>src\/main\/java\/com\/example\/Calculator.java<\/code> (Ayn\u0131 kal\u0131r):<\/strong><\/p>\n<pre><code class=\"language-java\">package com.example;\n\npublic class Calculator {\n    public int add(int a, int b) {\n        return a + b;\n    }\n\n    public int subtract(int a, int b) {\n        return a - b;\n    }\n\n    public int divide(int a, int b) {\n        if (b == 0) {\n            throw new ArithmeticException(\"S\u0131f\u0131ra b\u00f6lme hatas\u0131!\");\n        }\n        return a \/ b;\n    }\n}<\/code><\/pre>\n<p><strong><code>src\/test\/java\/com\/example\/CalculatorTest.java<\/code>:<\/strong><\/p>\n<pre><code class=\"language-java\">package com.example;\n\nimport org.junit.jupiter.api.*;\nimport static org.junit.jupiter.api.Assertions.*;\n\n@DisplayName(\"Calculator S\u0131n\u0131f\u0131 Testleri\") \/\/ Test s\u0131n\u0131f\u0131na a\u00e7\u0131klay\u0131c\u0131 isim verme\npublic class CalculatorTest {\n\n    private Calculator calculator;\n\n    @BeforeAll \/\/ T\u00fcm testlerden \u00f6nce bir kez \u00e7al\u0131\u015f\u0131r (statik olmal\u0131)\n    static void initAll() {\n        System.out.println(\"T\u00fcm testlerin ba\u015flang\u0131c\u0131: initAll metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @BeforeEach \/\/ Her test metodundan \u00f6nce \u00e7al\u0131\u015f\u0131r\n    void setUp() {\n        calculator = new Calculator();\n        System.out.println(\"Test ba\u015flang\u0131c\u0131: setUp metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @AfterEach \/\/ Her test metodundan sonra \u00e7al\u0131\u015f\u0131r\n    void tearDown() {\n        calculator = null;\n        System.out.println(\"Test biti\u015fi: tearDown metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @AfterAll \/\/ T\u00fcm testlerden sonra bir kez \u00e7al\u0131\u015f\u0131r (statik olmal\u0131)\n    static void tearDownAll() {\n        System.out.println(\"T\u00fcm testlerin biti\u015fi: tearDownAll metodu \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test\n    @DisplayName(\"\u0130ki say\u0131n\u0131n toplam\u0131n\u0131 do\u011fru hesaplamal\u0131\") \/\/ Test metoduna a\u00e7\u0131klay\u0131c\u0131 isim verme\n    void testAdd() {\n        int result = calculator.add(5, 3);\n        assertEquals(8, result, \"5 + 3 = 8 olmal\u0131\");\n        System.out.println(\"testAdd \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test\n    @DisplayName(\"\u0130ki say\u0131n\u0131n fark\u0131n\u0131 do\u011fru hesaplamal\u0131\")\n    void testSubtract() {\n        int result = calculator.subtract(10, 4);\n        assertEquals(6, result, \"10 - 4 = 6 olmal\u0131\");\n        System.out.println(\"testSubtract \u00e7al\u0131\u015ft\u0131.\");\n    }\n\n    @Test\n    @DisplayName(\"S\u0131f\u0131ra b\u00f6lme durumunda ArithmeticException f\u0131rlatmal\u0131\")\n    void testDivideByZero() {\n        \/\/ JUnit 5'te istisna test etme\n        ArithmeticException thrown = assertThrows(ArithmeticException.class, () -> {\n            calculator.divide(10, 0);\n        }, \"S\u0131f\u0131ra b\u00f6lme durumunda ArithmeticException f\u0131rlat\u0131lmal\u0131yd\u0131.\");\n\n        assertTrue(thrown.getMessage().contains(\"S\u0131f\u0131ra b\u00f6lme hatas\u0131!\"));\n    }\n\n    \/\/ Parametreli test \u00f6rne\u011fi (JUnit 5'in g\u00fc\u00e7l\u00fc \u00f6zelliklerinden biri)\n    \/\/ @ParameterizedTest\n    \/\/ @ValueSource(ints = {1, 2, 3})\n    \/\/ @DisplayName(\"Tek say\u0131lar i\u00e7in isOdd metodu true d\u00f6nmeli\")\n    \/\/ void testIsOdd(int number) {\n    \/\/     assertTrue(calculator.isOdd(number)); \/\/ Varsay\u0131msal isOdd metodu\n    \/\/ }\n}<\/code><\/pre>\n<p>JUnit 5&#8217;te anotasyonlar farkl\u0131 paketlerden gelir (<code>org.junit.jupiter.api<\/code>). <code>@BeforeEach<\/code> ve <code>@AfterEach<\/code> JUnit 4&#8217;teki <code>@Before<\/code> ve <code>@After<\/code>&#8216;\u0131n kar\u015f\u0131l\u0131\u011f\u0131d\u0131r. <code>@BeforeAll<\/code> ve <code>@AfterAll<\/code> ise JUnit 4&#8217;teki <code>@BeforeClass<\/code> ve <code>@AfterClass<\/code>&#8216;\u0131n kar\u015f\u0131l\u0131\u011f\u0131d\u0131r, ancak JUnit 5&#8217;te bu metotlar\u0131n <code>static<\/code> olmas\u0131na gerek yoktur (ancak <code>@BeforeAll<\/code> ve <code>@AfterAll<\/code> hala <code>static<\/code> olmal\u0131d\u0131r). <code>Assertions<\/code> s\u0131n\u0131f\u0131, JUnit 4&#8217;teki <code>Assert<\/code> s\u0131n\u0131f\u0131na g\u00f6re daha zengin ve lambda ifadelerini destekleyen metotlar sunar. <code>@DisplayName<\/code> anotasyonu, testlere daha okunabilir isimler vermenizi sa\u011flar, bu da raporlarda ve IDE&#8217;lerde test sonu\u00e7lar\u0131n\u0131 anlamay\u0131 kolayla\u015ft\u0131r\u0131r.<\/p>\n<h4>Testleri \u00c7al\u0131\u015ft\u0131rma<\/h4>\n<p>JUnit 5 testlerini de Maven ile \u00e7al\u0131\u015ft\u0131rmak i\u00e7in ayn\u0131 komutu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-bash\">mvn test<\/code><\/pre>\n<p><code>maven-surefire-plugin<\/code>&#8216;in do\u011fru yap\u0131land\u0131r\u0131lmas\u0131yla, JUnit 5 testleri ke\u015ffedilir ve \u00e7al\u0131\u015ft\u0131r\u0131l\u0131r. Sonu\u00e7lar yine <code>target\/surefire-reports\/<\/code> dizininde bulunabilir.<\/p>\n<h3>JUnit 4 ve JUnit 5 Aras\u0131ndaki Temel Farkl\u0131l\u0131klar<\/h3>\n<p>JUnit 4 ve JUnit 5, ayn\u0131 amaca hizmet etseler de, mimari ve kullan\u0131m a\u00e7\u0131s\u0131ndan \u00f6nemli farkl\u0131l\u0131klar g\u00f6sterirler.<\/p>\n<h4>Mimari<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> Monolitik bir yap\u0131ya sahiptir. T\u00fcm k\u00fct\u00fcphane tek bir JAR dosyas\u0131 (<code>junit.jar<\/code>) olarak gelir.<br \/>\n*   <strong>JUnit 5:<\/strong> Mod\u00fcler bir yap\u0131ya sahiptir (Platform, Jupiter, Vintage). Bu mod\u00fclerlik, daha fazla esneklik ve farkl\u0131 test motorlar\u0131n\u0131n ayn\u0131 platform \u00fczerinde \u00e7al\u0131\u015fabilmesini sa\u011flar.<\/p>\n<h4>Anotasyonlar<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> Anotasyonlar\u0131 <code>org.junit<\/code> paketinden gelir (<code>@Test<\/code>, <code>@Before<\/code>, <code>@After<\/code>, <code>@BeforeClass<\/code>, <code>@AfterClass<\/code>).<br \/>\n*   <strong>JUnit 5:<\/strong> Anotasyonlar\u0131 <code>org.junit.jupiter.api<\/code> paketinden gelir (<code>@Test<\/code>, <code>@BeforeEach<\/code>, <code>@AfterEach<\/code>, <code>@BeforeAll<\/code>, <code>@AfterAll<\/code>, <code>@DisplayName<\/code>). Baz\u0131 isimler de\u011fi\u015fmi\u015f, baz\u0131lar\u0131 ise ayn\u0131 kalm\u0131\u015ft\u0131r ancak farkl\u0131 paketlerdedir.<\/p>\n<h4>Geni\u015fletilebilirlik Modeli<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> <code>Runners<\/code> (\u00f6rne\u011fin, <code>Parameterized<\/code>, <code>SpringJUnit4ClassRunner<\/code>) kullanarak geni\u015fletilebilirlik sa\u011flar.<br \/>\n*   <strong>JUnit 5:<\/strong> <code>Extension Model<\/code>&#8216;i kullan\u0131r. <code>@ExtendWith<\/code> anotasyonu ile daha g\u00fc\u00e7l\u00fc ve esnek bir geni\u015fletilebilirlik sunar. Bu model, test ya\u015fam d\u00f6ng\u00fcs\u00fcn\u00fcn \u00e7e\u015fitli noktalar\u0131na m\u00fcdahale etmeyi kolayla\u015ft\u0131r\u0131r.<\/p>\n<h4>Varsay\u0131lan Eri\u015fim Belirleyiciler<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> Test metotlar\u0131n\u0131n <code>public<\/code> olmas\u0131 zorunludur. Test s\u0131n\u0131f\u0131n\u0131n da <code>public<\/code> olmas\u0131 beklenir.<br \/>\n*   <strong>JUnit 5:<\/strong> Test metotlar\u0131 ve s\u0131n\u0131flar\u0131 i\u00e7in <code>public<\/code> zorunlulu\u011fu yoktur. <code>package-private<\/code> (varsay\u0131lan) veya <code>private<\/code> metotlar da test edilebilir, bu da daha esnek bir yap\u0131 sunar.<\/p>\n<h4>Parametreli Testler<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> <code>Parameterized<\/code> runner ile parametreli testler yazmak m\u00fcmk\u00fcnd\u00fcr, ancak kurulumu daha karma\u015f\u0131kt\u0131r ve \u00f6zel bir runner gerektirir.<br \/>\n*   <strong>JUnit 5:<\/strong> <code>@ParameterizedTest<\/code>, <code>@ValueSource<\/code>, <code>@CsvSource<\/code>, <code>@MethodSource<\/code> gibi yerle\u015fik anotasyonlarla \u00e7ok daha g\u00fc\u00e7l\u00fc ve kolay parametreli testler sunar.<\/p>\n<h4>Dinamik Testler<\/h4>\n<p>*   <strong>JUnit 5:<\/strong> <code>DynamicTest<\/code> API&#8217;si sayesinde \u00e7al\u0131\u015fma zaman\u0131nda testler olu\u015fturulabilir. Bu \u00f6zellik JUnit 4&#8217;te bulunmamaktad\u0131r.<\/p>\n<h4>Varsay\u0131mlar (Assumptions)<\/h4>\n<p>*   <strong>JUnit 4:<\/strong> <code>org.junit.Assume<\/code> s\u0131n\u0131f\u0131n\u0131 kullan\u0131r.<br \/>\n*   <strong>JUnit 5:<\/strong> <code>org.junit.jupiter.api.Assumptions<\/code> s\u0131n\u0131f\u0131n\u0131 kullan\u0131r ve lambda ifadeleriyle daha okunabilir bir yap\u0131 sunar.<\/p>\n<h3>JUnit Testleri i\u00e7in En \u0130yi Uygulamalar (Best Practices)<\/h3>\n<p>Etkili birim testleri yazmak, sadece s\u00f6z dizimini bilmekle kalmaz, ayn\u0131 zamanda belirli prensipleri ve en iyi uygulamalar\u0131 takip etmeyi de gerektirir.<\/p>\n<h4>Test Metotlar\u0131n\u0131 Anlaml\u0131 Adland\u0131rma<\/h4>\n<p>Test metotlar\u0131n\u0131z\u0131n neyi test etti\u011fini a\u00e7\u0131k\u00e7a belirten isimler kullan\u0131n. \u00d6rne\u011fin, <code>testAdd()<\/code> yerine <code>shouldReturnSumOfTwoNumbers()<\/code> veya <code>add_PositiveNumbers_ReturnsCorrectSum()<\/code> gibi isimler daha a\u00e7\u0131klay\u0131c\u0131d\u0131r. JUnit 5&#8217;teki <code>@DisplayName<\/code> anotasyonu bu konuda ek bir esneklik sunar.<\/p>\n<h4>Test \u0130zolasyonu<\/h4>\n<p>Her test ba\u011f\u0131ms\u0131z olmal\u0131d\u0131r. Bir testin sonucu, ba\u015fka bir testin \u00e7al\u0131\u015ft\u0131r\u0131lmas\u0131ndan veya s\u0131ras\u0131ndan etkilenmemelidir. <code>@BeforeEach<\/code> ve <code>@AfterEach<\/code> (JUnit 5) veya <code>@Before<\/code> ve <code>@After<\/code> (JUnit 4) metotlar\u0131n\u0131 kullanarak her test i\u00e7in temiz bir ortam sa\u011flay\u0131n.<\/p>\n<h4>Sadece Bir \u015eeyi Test Etme (Single Responsibility)<\/h4>\n<p>Her test metodu yaln\u0131zca tek bir senaryoyu veya birim i\u015flevselli\u011fini test etmelidir. Bu, bir testin ba\u015far\u0131s\u0131z olmas\u0131 durumunda hatan\u0131n nerede oldu\u011funu anlamay\u0131 kolayla\u015ft\u0131r\u0131r.<\/p>\n<h4>H\u0131zl\u0131 Testler<\/h4>\n<p>Birim testleri h\u0131zl\u0131 \u00e7al\u0131\u015fmal\u0131d\u0131r. Binlerce testin bile saniyeler i\u00e7inde tamamlanmas\u0131 hedeflenmelidir. D\u0131\u015f ba\u011f\u0131ml\u0131l\u0131klardan (veritaban\u0131, a\u011f, dosya sistemi) ka\u00e7\u0131n\u0131n veya bunlar\u0131 <code>mock<\/code>&#8216;lay\u0131n\/<code>stub<\/code>&#8216;lay\u0131n.<\/p>\n<h4>Okunabilir Testler: AAA Deseni<\/h4>\n<p>Testlerinizi <strong>Arrange-Act-Assert (AAA)<\/strong> deseniyle d\u00fczenleyin:<br \/>\n*   <strong>Arrange (Haz\u0131rl\u0131k):<\/strong> Test i\u00e7in gerekli nesneleri ve verileri haz\u0131rlay\u0131n.<br \/>\n*   <strong>Act (Eylem):<\/strong> Test edilen metodu veya i\u015flevselli\u011fi \u00e7a\u011f\u0131r\u0131n.<br \/>\n*   <strong>Assert (Do\u011frulama):<\/strong> Eylemin sonucunun beklendi\u011fi gibi oldu\u011funu do\u011frulay\u0131n.<\/p>\n<pre><code class=\"language-java\">@Test\nvoid shouldReturnSumOfTwoNumbers() {\n    \/\/ Arrange\n    Calculator calculator = new Calculator();\n    int num1 = 5;\n    int num2 = 3;\n    int expectedSum = 8;\n\n    \/\/ Act\n    int actualSum = calculator.add(num1, num2);\n\n    \/\/ Assert\n    assertEquals(expectedSum, actualSum);\n}<\/code><\/pre>\n<h4>Kapsaml\u0131l\u0131k (Coverage)<\/h4>\n<p>Test kapsam\u0131, kodunuzun ne kadar\u0131n\u0131n testler taraf\u0131ndan kapsand\u0131\u011f\u0131n\u0131 g\u00f6sterir. Y\u00fcksek test kapsam\u0131, genellikle daha g\u00fcvenilir bir yaz\u0131l\u0131ma i\u015faret eder. Ancak %100 kapsama k\u00f6r\u00fc k\u00f6r\u00fcne ula\u015fmaya \u00e7al\u0131\u015fmak yerine, kritik i\u015f mant\u0131\u011f\u0131n\u0131 kapsayan anlaml\u0131 testler yazmaya odaklan\u0131n. JaCoCo gibi ara\u00e7lar test kapsam\u0131n\u0131 \u00f6l\u00e7menize yard\u0131mc\u0131 olabilir.<\/p>\n<h4>D\u0131\u015f Ba\u011f\u0131ml\u0131l\u0131klardan Ka\u00e7\u0131nma\/Mocklama<\/h4>\n<p>Veritaban\u0131, harici API&#8217;ler, dosya sistemi gibi d\u0131\u015f ba\u011f\u0131ml\u0131l\u0131klar, birim testlerini yava\u015flat\u0131r ve onlar\u0131 k\u0131r\u0131lgan hale getirir. Bu t\u00fcr ba\u011f\u0131ml\u0131l\u0131klar\u0131 <code>Mockito<\/code> gibi k\u00fct\u00fcphanelerle <code>mock<\/code>&#8216;layarak veya <code>stub<\/code>&#8216;layarak testlerinizi izole edin ve h\u0131zland\u0131r\u0131n.<\/p>\n<h3>S\u0131k Kar\u015f\u0131la\u015f\u0131lan Sorunlar ve \u00c7\u00f6z\u00fcmleri<\/h3>\n<p>JUnit ve Maven ile \u00e7al\u0131\u015f\u0131rken kar\u015f\u0131la\u015f\u0131labilecek baz\u0131 yayg\u0131n sorunlar ve bunlar\u0131n \u00e7\u00f6z\u00fcmleri \u015funlard\u0131r:<\/p>\n<h4>Ba\u011f\u0131ml\u0131l\u0131k \u00c7ak\u0131\u015fmalar\u0131<\/h4>\n<p>Farkl\u0131 k\u00fct\u00fcphanelerin ayn\u0131 ba\u011f\u0131ml\u0131l\u0131\u011f\u0131n farkl\u0131 versiyonlar\u0131n\u0131 gerektirmesi durumunda ba\u011f\u0131ml\u0131l\u0131k \u00e7ak\u0131\u015fmalar\u0131 ya\u015fanabilir.<br \/>\n*   <strong>\u00c7\u00f6z\u00fcm:<\/strong> <code>mvn dependency:tree<\/code> komutunu kullanarak ba\u011f\u0131ml\u0131l\u0131k a\u011fac\u0131n\u0131 inceleyin ve \u00e7ak\u0131\u015fan ba\u011f\u0131ml\u0131l\u0131klar\u0131 tespit edin. <code><exclusions><\/code> etiketini kullanarak istenmeyen ba\u011f\u0131ml\u0131l\u0131klar\u0131 hari\u00e7 tutabilir veya <code><dependencyManagement><\/code> b\u00f6l\u00fcm\u00fcnde belirli bir versiyonu zorunlu k\u0131labilirsiniz.<\/p>\n<h4>Surefire Plugin Yap\u0131land\u0131rma Hatalar\u0131<\/h4>\n<p><code>maven-surefire-plugin<\/code>&#8216;in yanl\u0131\u015f yap\u0131land\u0131r\u0131lmas\u0131 veya eski bir versiyonunun kullan\u0131lmas\u0131, testlerin \u00e7al\u0131\u015fmamas\u0131na veya yanl\u0131\u015f sonu\u00e7lar vermesine neden olabilir.<br \/>\n*   <strong>\u00c7\u00f6z\u00fcm:<\/strong> \u00d6zellikle JUnit 5 kullan\u0131rken <code>maven-surefire-plugin<\/code>&#8216;in 2.22.0 veya daha yeni bir s\u00fcr\u00fcm\u00fcn\u00fc kulland\u0131\u011f\u0131n\u0131zdan emin olun. <code>pom.xml<\/code>&#8216;deki plugin yap\u0131land\u0131rmas\u0131n\u0131 dikkatlice kontrol edin.<\/p>\n<h4>Testlerin Ke\u015ffedilememesi<\/h4>\n<p>Maven&#8217;\u0131n <code>mvn test<\/code> komutunu \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131n\u0131zda testlerin bulunamamas\u0131 veya hi\u00e7 \u00e7al\u0131\u015fmamas\u0131.<br \/>\n*   <strong>\u00c7\u00f6z\u00fcm:<\/strong><br \/>\n    *   Test s\u0131n\u0131flar\u0131n\u0131z\u0131n ve metotlar\u0131n\u0131z\u0131n do\u011fru JUnit anotasyonlar\u0131na sahip oldu\u011fundan emin olun (<code>@Test<\/code>).<br \/>\n    *   Test s\u0131n\u0131flar\u0131n\u0131z\u0131n Maven&#8217;\u0131n varsay\u0131lan test dizin yap\u0131s\u0131na uygun oldu\u011fundan emin olun (<code>src\/test\/java<\/code>).<br \/>\n    <em>   Test s\u0131n\u0131flar\u0131n\u0131z\u0131n isimlerinin <code><\/em>Test.java<\/code>, <code>Test<em>.java<\/code>, <code><\/em>Tests.java<\/code> veya <code>*TestCase.java<\/code> gibi Maven&#8217;\u0131n varsay\u0131lan ke\u015fif desenlerine uydu\u011fundan emin olun.<br \/>\n    *   <code>maven-surefire-plugin<\/code>&#8216;in do\u011fru versiyonunu kulland\u0131\u011f\u0131n\u0131z\u0131 kontrol edin.<\/p>\n<h4>Java Versiyon Uyu\u015fmazl\u0131\u011f\u0131<\/h4>\n<p>JUnit 5, Java 8 veya daha yeni bir s\u00fcr\u00fcm gerektirir. E\u011fer projeniz eski bir Java s\u00fcr\u00fcm\u00fcyle derleniyorsa, JUnit 5 testleri \u00e7al\u0131\u015fmayabilir.<br \/>\n*   <strong>\u00c7\u00f6z\u00fcm:<\/strong> <code>maven-compiler-plugin<\/code>&#8216;in <code>source<\/code> ve <code>target<\/code> versiyonlar\u0131n\u0131n Java 8 veya \u00fczeri bir s\u00fcr\u00fcme ayarland\u0131\u011f\u0131ndan emin olun.<\/p>\n<pre><code class=\"language-xml\"><plugin>\n    <groupId>org.apache.maven.plugins<\/groupId>\n    <artifactId>maven-compiler-plugin<\/artifactId>\n    <version>3.11.0<\/version>\n    <configuration>\n        <source>11<\/source> <!-- Minimum Java 8 -->\n        <target>11<\/target>\n    <\/configuration>\n<\/plugin><\/code><\/pre>\n<h3>Sonu\u00e7: G\u00fc\u00e7l\u00fc Test Altyap\u0131s\u0131 ile Daha Sa\u011flam Yaz\u0131l\u0131mlar<\/h3>\n<p>Bu makale boyunca, Java projelerinde birim testlerinin temel ta\u015f\u0131 olan JUnit 4 ve JUnit 5&#8217;in Maven ile nas\u0131l kurulaca\u011f\u0131n\u0131 ve kullan\u0131laca\u011f\u0131n\u0131 detayl\u0131 bir \u015fekilde inceledik. Maven&#8217;\u0131n ba\u011f\u0131ml\u0131l\u0131k y\u00f6netimi ve build otomasyonu konusundaki g\u00fcc\u00fcyle birle\u015fen JUnit, yaz\u0131l\u0131m geli\u015ftiricilere g\u00fcvenilir ve s\u00fcrd\u00fcr\u00fclebilir kod yazma konusunda paha bi\u00e7ilmez bir destek sunar.<\/p>\n<p>JUnit 4, basitli\u011fi ve uzun ge\u00e7mi\u015fiyle hala bir\u00e7ok projede kullan\u0131lmaktad\u0131r. Ancak JUnit 5, mod\u00fcler mimarisi, zengin anotasyon seti ve g\u00fc\u00e7l\u00fc geni\u015fletilebilirlik modeliyle modern Java uygulamalar\u0131 i\u00e7in daha esnek ve g\u00fc\u00e7l\u00fc bir test deneyimi sa\u011flar. Her iki s\u00fcr\u00fcm\u00fcn de kendine \u00f6zg\u00fc avantajlar\u0131 ve kullan\u0131m senaryolar\u0131 vard\u0131r, ancak yeni projelerde JUnit 5&#8217;i tercih etmek, gelece\u011fe y\u00f6nelik daha sa\u011flam bir temel olu\u015fturacakt\u0131r.<\/p>\n<p>Unutulmamal\u0131d\u0131r ki, test yazmak sadece bir k\u00fct\u00fcphanenin s\u00f6zdizimini \u00f6\u011frenmekten ibaret de\u011fildir. \u0130yi testler, kodun kalitesini art\u0131ran, hatalar\u0131 erken bulan ve geli\u015ftirme s\u00fcrecini h\u0131zland\u0131ran bir yat\u0131r\u0131m arac\u0131d\u0131r. Bu rehberdeki bilgileri ve en iyi uygulamalar\u0131 kullanarak, siz de projelerinizde daha sa\u011flam, daha g\u00fcvenilir ve daha bak\u0131m\u0131 kolay yaz\u0131l\u0131mlar geli\u015ftirebilirsiniz. S\u00fcrekli test etme prati\u011fini benimseyerek, yaz\u0131l\u0131m kalitesini en \u00fcst seviyede tutma yolunda \u00f6nemli bir ad\u0131m atm\u0131\u015f olacaks\u0131n\u0131z.<br \/>\n<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi\nGiri\u015f: Yaz\u0131l\u0131m Kalitesinde Testin \u00d6nemi ve JUnit&#8217;in Rol\u00fc\nYaz\u0131l\u0131m geli\u015ftirme s","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-37052","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-genel","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi\" \/>\n<meta property=\"og:description\" content=\"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi Giri\u015f: Yaz\u0131l\u0131m Kalitesinde Testin \u00d6nemi ve JUnit&#039;in Rol\u00fc Yaz\u0131l\u0131m geli\u015ftirme s\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-12-26T17:40:52+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi\",\"datePublished\":\"2025-12-26T17:40:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\"},\"wordCount\":2442,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\",\"name\":\"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-12-26T17:40:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/","og_locale":"tr_TR","og_type":"article","og_title":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi","og_description":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi Giri\u015f: Yaz\u0131l\u0131m Kalitesinde Testin \u00d6nemi ve JUnit'in Rol\u00fc Yaz\u0131l\u0131m geli\u015ftirme s","og_url":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-12-26T17:40:52+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"16 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi","datePublished":"2025-12-26T17:40:52+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/"},"wordCount":2442,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/","url":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/","name":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-12-26T17:40:52+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/junit-kurulumu-maven-ile-junit-4-ve-junit-5-kapsamli-rehberi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JUnit Kurulumu Maven ile: JUnit 4 ve JUnit 5 Kapsaml\u0131 Rehberi"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=37052"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37052\/revisions"}],"predecessor-version":[{"id":37053,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/37052\/revisions\/37053"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=37052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=37052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=37052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}