8000 GitHub - WasiqB/coteafs-datasource at v1.0.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WasiqB/coteafs-datasource

Repository files navigation

coteafs-datasource

Open Source Love CircleCI

Maven Central Github Releases License

Usage 🏃

Dependency

<dependency>
  <groupId>com.github.wasiqb.coteafs</groupId>
  <artifactId>datasource</artifactId>
  <version>1.0.0</version>
</dependency>

Example

Pojo Classes

Pojo class for our data file login-data.yml.

import java.util.List;

import com.github.wasiqb.coteafs.datasource.annotation.DataFile;
import lombok.Data;

@Data
@DataFile
public class LoginData {
    private List<Login> loginData;
}

@Data
public class Login {
    private String password;
    private String userName;
}

Data file content

Data for our Yml data file login-data.yml.

login_data:
  - user_name: WasiqB
    password: Admin
  - user_name: FaisalK
    password: Abcd

Parsing data file

Following is an example to convert data file into a TestNG data provider.

import static com.google.common.truth.Truth.assertWithMessage;

import com.github.wasiqb.coteafs.datasource.data.LoginData;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class DataSourceYmlTest {
    @DataProvider
    public Iterator<Object[]> getLoginDataYml () {
        final LoginData loginData = DataSource.parse (LoginData.class);
        final List<Object[]> data = new ArrayList<> ();
        loginData.getLoginData ()
            .forEach (d -> data.add (new Object[] { d }));
        return data.iterator ();
    }
    
    @Test (dataProvider = "getLoginDataYml")
    public void testYmlDataSource (final Login login) {
        assertWithMessage ("User Name").that (login.getUserName ())
            .isNotEmpty ();
        assertWithMessage ("Password").that (login.getPassword ())
            .isNotEmpty ();
    }
}

Contributors ✨

Thanks to these wonderful people (emoji key):


Mohammad Faisal Khatri

⚠️

Wasiq Bhamla

💻 ⚠️ 🚇 📖 🤔 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

About

📒 Simple Data file to object parser supports JSON, YML, XML and properties file format.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Contributors 2

  •  
  •  

Languages

0