Executing JUnit tests in testng

TestNG allows you to execute JUnit tests from within TestNG framework. Below example demonstrates how to run JUnit tests. Note that we have used org.junit.Test annotation in below example.
package org.softpost;

import org.junit.Test;

public class JunitTests {

    public void test1(){
        System.out.println("Junit test");

Here is the TestNG XML file. Note that in test tag, we have used a special attribute called as junit and it’s value is set as true. TestNG executes JUnit tests using JunitCore.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite" parallel="false">
    <test name="Tests" junit="true">
            <class name="org.softpost.JunitTests" />

Web development and Automation testing

solutions delivered!!