By using Maven, you streamline the process of managing dependencies and building your Java projects, ensuring a standardized approach and reducing manual efforts.
o/p:
---
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.birla:MavenProjectThroughCommand >----------------
[INFO] Building MavenProjectThroughCommand 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ MavenProjectThroughCommand ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ MavenProjectThroughCommand ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ MavenProjectThroughCommand ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.birla.AppTest
running maven test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.111 s - in com.birla.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.150 s
[INFO] Finished at: 2024-06-19T08:21:15+05:30
[INFO] ------------------------------------------------------------------------
-----------------------
Create class = MobileTest :
----------------------------
package com.birla;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class MobileTest
{
@Test
public void testA()
{
System.out.println("Calling Mobile Test");
assertTrue( true );
}
}
Run Mave test :
---------------
Right click on project > run as "Maven tests"
When we run as maven tests > it goes to "src/test/java" folder > it runs all classes where class name ends with "Test"
o/p:
-----
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.birla:MavenProjectThroughCommand >----------------
[INFO] Building MavenProjectThroughCommand 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ MavenProjectThroughCommand ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ MavenProjectThroughCommand ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ MavenProjectThroughCommand ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.birla.AppTest
running maven test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.097 s - in com.birla.AppTest
[INFO] Running com.birla.MobileTest
Calling Mobile Test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in com.birla.MobileTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.137 s
[INFO] Finished at: 2024-06-19T08:25:32+05:30
[INFO] ------------------------------------------------------------------------
-----------------------------
Create class = AndroidTest :
-----------------------
package com.birla;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class AndroidTest
{
@Test
public void testB()
{
System.out.println("Calling Android Test");
assertTrue( true );
}
}
--------------------------------------
Run Maven tests :
------------------------
Right click on project > run as "Maven tests"
When we run as maven tests > it goes to "src/test/java" folder > it runs all classes where class name ends with "Test"
o/p:
----
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.birla:MavenProjectThroughCommand >----------------
[INFO] Building MavenProjectThroughCommand 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ MavenProjectThroughCommand ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ MavenProjectThroughCommand ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ MavenProjectThroughCommand ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.birla.AndroidTest
Calling Android Test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.173 s - in com.birla.AndroidTest
[INFO] Running com.birla.AppTest
running maven test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in com.birla.AppTest
[INFO] Running com.birla.MobileTest
Calling Mobile Test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in com.birla.MobileTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.626 s
[INFO] Finished at: 2024-06-19T08:29:43+05:30
[INFO] ------------------------------------------------------------------------
-------------------------------
Create class name without Test : ios
--------------------------------
package com.birla;
import org.junit.Test;
class ios // this class will not get executed as Class name does end with Test
//class IOSTest // gets executed
// class IOS // this class will not get executed as Class name does end with 'Test'
// class IOStest // does not get executed as class name does not end with "Test"
// always Give Test, but not 'test'
// class IOSTEST //// does not get executed as class name does not end with "Test
{
@Test
public void testC()
{
System.out.println("hi IOS Test");
}
}
--------------------------------------
• Run Maven tests :
------------------------
Right click on project > run as "Maven tests"
When we run as maven tests > it goes to "src/test/java" folder > it runs all classes where class name ends with "Test"
console o/p:
--------------
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/C:/brahma/seleniumSoftwares/eclipse-jee-2021-03-M2-win32-x86_64/eclipse/configuration/org.eclipse.osgi/6/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.birla:MavenProjectThroughCommand >----------------
[INFO] Building MavenProjectThroughCommand 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ MavenProjectThroughCommand ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ MavenProjectThroughCommand ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\brahma\Practise\SelniumPractiseNew\March52024MyWorkspace\MavenProjectThroughCommand\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ MavenProjectThroughCommand ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ MavenProjectThroughCommand ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.birla.AndroidTest
Calling Android Test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.148 s - in com.birla.AndroidTest
[INFO] Running com.birla.AppTest
running maven test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.007 s - in com.birla.AppTest
[INFO] Running com.birla.MobileTest
Calling Mobile Test
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in com.birla.MobileTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.838 s
[INFO] Finished at: 2024-06-19T08:40:26+05:30
[INFO] ------------------------------------------------------------------------
***************************************************
HW Create Maven test classes in "src/test/java" and run as maven test as same as previous program?
No comments:
Post a Comment