> For the complete documentation index, see [llms.txt](https://bharateeshd.gitbook.io/seleniumatoz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bharateeshd.gitbook.io/seleniumatoz/testng/first-test-script.md).

# First Test Script

Creating out first test script and understanding it

## Creating First Test Script

1. Create a package in `src/test/java` called `com.practice` (Can be anything).
2. Create a class `FirstTest.java` like below.

```java
package com.practice;

import org.testng.Assert;
import org.testng.annotations.Test;

public class FirstTest {

	@Test
	public void helloworldTest() {
		String message = "Hello world!!";
		Assert.assertTrue(message.contains("Hello"));
	}
	
	@Test
	public void failingTestCase() {
		String message = "Hello world!!";
		Assert.assertTrue(message.contains("hello"));
	}
}
```

3\. Run the test cases.\
`<right-click-class> -> Run As-> TestNG Test` This option should appear if you have installed TestNG plugin to eclipse.

4\.  Console output\
Once we run the test, we should see something like this in the console

![Console Output](https://33776268-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkzK2upwwx1UGyuYl-Y%2F-MJpjS3YVKar7lulzW57%2F-MJpkmPBNSpMSeTzUIUe%2FScreenshot%20from%202020-10-17%2014-21-55.png?alt=media\&token=aac3b10a-0280-4fac-bf23-25c9a4533065)

{% hint style="info" %}
We are intentionally failing the second test.
{% endhint %}

## Understanding the `FirstTest`

* Our `FirstTest` class has two methods both annotated with `@Test` annotation. So in TestNG all the methods that are annotated with `@Test` annotation are test methods or test cases.
* `@Test` can be applied on class level also. In that case it'll consider all the public methods in the class as test methods.
*

So we we run the test case using TestNG plugin, keep in mind that we are not the one who created instance of `FirstTest.java` and called `helloworldTest()` and `failingTestCase()` . TestNG did it. (This is why we use testing frameworks like JUnit, TestNG etc.,)

And what goes inside those test methods is entirely in our hand.

{% hint style="info" %}
&#x20;We can use both `org.junit.Assert` and  `org.testng.Assert`
{% endhint %}
