Skip to content

Commit 2c284e9

Browse files
authored
Update README.md
1 parent afb2062 commit 2c284e9

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,81 @@ The project is structured as follows:
105105
            ├─ login.csv
106106
            └─ products.csv
107107
```
108+
109+
## Basic Usage
110+
111+
- ### Configuration
112+
The project uses a [*config.properties*](./src/test/resources/config.properties) file to manage global configurations such as browser type and base url.
113+
114+
1. To add a new property, register a new entry in this file.
115+
```
116+
key=value
117+
```
118+
119+
Then, add a method in the [*Configuration*](./src/main/java/io/github/tahanima/config/Configuration.java) interface in the below format.
120+
```java
121+
@Key("key")
122+
dataType key();
123+
```
124+
125+
For example, let's say I want to add a new property named `context` with the value `dev`. In the `config.properties` file, I'll add:
126+
```
127+
context=dev
128+
```
129+
130+
In the `Configuration` interface, I'll add:
131+
```java
132+
@Key("context")
133+
String context();
134+
```
135+
136+
To use your newly created property, you need to use the below import statement.
137+
```java
138+
import static io.github.tahanima.config.ConfigurationManager.config;
139+
```
140+
141+
Then, you can call `config().key()` to retrieve the value of your newly created property. For the example I've provided, I need to call `config().context()`.
142+
143+
2. You can supply the properties present in the `config.properties` file as system properties in your test via gradle.
144+
```bash
145+
./gradlew test -Dkey1=value1 -Dkey2=value2
146+
```
147+
148+
- ### Test Data
149+
The project uses *csv* file to store test data and [*univocity-parsers*](https://github.com/uniVocity/univocity-parsers) to retrieve the data and map it to a Java bean.
150+
151+
To add configurations for new test data, add a new Java bean in the [*data*](./src/main/java/io/github/tahanima/data) package. For example, let's say I want to add test data for a `User` with the attributes `First Name` and `Last Name`. The code for this is as follows:
152+
153+
```java
154+
package io.github.tahanima.data;
155+
156+
import com.univocity.parsers.annotations.Parsed;
157+
158+
import lombok.Getter;
159+
import lombok.ToString;
160+
161+
@Getter
162+
@ToString(callSuper = true)
163+
public class UserData extends BaseData {
164+
165+
@Parsed(field = "First Name", defaultNullRead = "")
166+
private String firstName;
167+
168+
@Parsed(field = "Last Name", defaultNullRead = "")
169+
private String lastName;
170+
}
171+
```
172+
Note that the class extends from BaseData and thus, inherits the attribute `Test Case ID`.
173+
174+
Now, in the [*testdata*](./src/test/resources/testdata) folder you can add a csv file `user.csv` for `User` with the below contents and use it in your tests.
175+
```
176+
Test Case ID,First Name,Last Name
177+
TC-1,Tahanima,Chowdhury
178+
```
179+
For reference, check [this](./src/main/java/io/github/tahanima/data/LoginData.java), [this](./src/test/resources/testdata/login.csv) and [this](./src/test/java/io/github/tahanima/e2e/LoginE2ETest.java).
180+
181+
- ### Page Objects and Page Component Objects
182+
The project uses [*Page Objects* and *Page Component Objects*](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) to capture the relevant behaviors of a web page. Check the [*ui*](./src/main/java/io/github/tahanima/ui) package for reference.
183+
184+
- ### Tests
185+
The project uses *TestNG* as the test runner. Check [this implementation](./src/test/java/io/github/tahanima/e2e/LoginE2ETest.java) for reference.

0 commit comments

Comments
 (0)