{
29 | @SneakyThrows
30 | @Override
31 | public Double convert(final String value) {
32 | return NumberFormat.getInstance(Locale.getDefault()).parse(value).doubleValue();
33 | }
34 |
35 | @Override
36 | public Type getType() {
37 | return Double.TYPE;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/converters/IntegerConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.converters;
18 |
19 | import java.lang.reflect.Type;
20 |
21 | import static java.lang.Integer.parseInt;
22 |
23 | /**
24 | * "This class converts a String to an Integer."
25 | *
26 | * The class extends DefaultConverter, which is a class that implements the
27 | * Converter interface
28 | */
29 | public class IntegerConverter extends DefaultConverter {
30 | @Override
31 | public Integer convert(final String value) {
32 | return parseInt(value);
33 | }
34 |
35 | @Override
36 | public Type getType() {
37 | return Integer.TYPE;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/converters/LocalDateConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.converters;
18 |
19 | import io.github.selcukes.collections.Clocks;
20 |
21 | import java.time.LocalDate;
22 |
23 | import static io.github.selcukes.collections.Clocks.DATE_FORMAT;
24 | import static java.time.LocalDate.parse;
25 |
26 | /**
27 | * It converts a string to a `LocalDate` object
28 | */
29 | public class LocalDateConverter extends DefaultConverter {
30 | @Override
31 | public LocalDate convert(final String value) {
32 | return convert(value, DATE_FORMAT);
33 | }
34 |
35 | @Override
36 | public LocalDate convert(final String value, final String format) {
37 | return parse(value, Clocks.dateTimeFormatter(format, DATE_FORMAT));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/converters/LocalDateTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.converters;
18 |
19 | import io.github.selcukes.collections.Clocks;
20 |
21 | import java.time.LocalDateTime;
22 |
23 | import static io.github.selcukes.collections.Clocks.DATE_TIME_FORMAT;
24 | import static java.time.LocalDateTime.parse;
25 |
26 | /**
27 | * It converts a string to a `LocalDateTime` object
28 | */
29 | public class LocalDateTimeConverter extends DefaultConverter {
30 |
31 | @Override
32 | public LocalDateTime convert(final String value) {
33 | return convert(value, DATE_TIME_FORMAT);
34 | }
35 |
36 | @Override
37 | public LocalDateTime convert(final String value, final String format) {
38 | return parse(value, Clocks.dateTimeFormatter(format, DATE_TIME_FORMAT));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/converters/StringConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.converters;
18 |
19 | /**
20 | * "This class converts a String to a String."
21 | *
22 | * The `DefaultConverter` class is a generic class that takes a single type
23 | * parameter. In this case, the type parameter is `String`. The
24 | * `DefaultConverter` class is an abstract class that requires you to implement
25 | * the `convert` method. The `convert` method takes a single parameter of type
26 | * `String` and returns a `String`
27 | */
28 | public class StringConverter extends DefaultConverter {
29 | @Override
30 | public String convert(final String value) {
31 | return value;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/exception/DataMapperException.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.databind.exception;
20 |
21 | public class DataMapperException extends RuntimeException {
22 |
23 | private static final long serialVersionUID = 1L;
24 |
25 | public DataMapperException() {
26 | super();
27 | }
28 |
29 | public DataMapperException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 |
33 | public DataMapperException(String message) {
34 | super(message);
35 | }
36 |
37 | public DataMapperException(Throwable cause) {
38 | super(cause);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/properties/PropertiesLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.properties;
18 |
19 | import io.github.selcukes.databind.exception.DataMapperException;
20 |
21 | import java.io.FileInputStream;
22 | import java.io.IOException;
23 | import java.nio.file.Path;
24 | import java.util.Properties;
25 |
26 | class PropertiesLoader {
27 | private PropertiesLoader() {
28 | }
29 |
30 | public static Properties getProperties(Path filePath) {
31 | var properties = new Properties();
32 | try (var stream = new FileInputStream(filePath.toFile())) {
33 | properties.load(stream);
34 | } catch (IOException e) {
35 | throw new DataMapperException("Could not parse property file '" + filePath.toFile().getName() + "'", e);
36 | }
37 | return properties;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/substitute/DefaultSubstitutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.substitute;
18 |
19 | import java.util.Properties;
20 |
21 | /**
22 | * It does nothing
23 | */
24 | public class DefaultSubstitutor implements Substitutor {
25 | public String replace(final Properties variables, final String key, final String format) {
26 | return variables.getProperty(key);
27 | }
28 |
29 | @Override
30 | public String replace(final String strToReplace, final String format) {
31 | return strToReplace;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/substitute/StringSubstitutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.substitute;
18 |
19 | import io.github.selcukes.collections.StringHelper;
20 | import io.github.selcukes.databind.utils.DataSubstitutor;
21 |
22 | import java.util.Properties;
23 |
24 | /**
25 | * It replaces all occurrences of ${key} with the value of the key in the
26 | * properties object
27 | */
28 | public class StringSubstitutor extends DefaultSubstitutor {
29 |
30 | @Override
31 | public String replace(final Properties variables, final String key, final String format) {
32 | String value = variables.getProperty(key);
33 | return StringHelper.interpolate(value, matcher -> DataSubstitutor.substitute(matcher, format));
34 | }
35 |
36 | @Override
37 | public String replace(final String strToReplace, final String format) {
38 | return StringHelper.interpolate(strToReplace, matcher -> DataSubstitutor.substitute(matcher, format));
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/selcukes-databind/src/main/java/io/github/selcukes/databind/substitute/Substitutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.substitute;
18 |
19 | import java.util.Properties;
20 |
21 | // A Java interface.
22 | public interface Substitutor {
23 | /**
24 | * Replace all occurrences of variables within the value associated with the
25 | * given key in the given properties, optionally formatting them
26 | *
27 | * @param variables The variables to use for replacement.
28 | * @param key The key to be replaced.
29 | * @param format The format of the string to be replaced.
30 | * @return A string with the value of the key in the properties
31 | * file.
32 | */
33 | String replace(Properties variables, String key, final String format);
34 |
35 | /**
36 | * It replaces all occurrences of the string "strToReplace" with the string
37 | * "format".
38 | *
39 | * @param strToReplace The string to be replaced.
40 | * @param format The format of the string to be replaced.
41 | * @return A string with the format of the date.
42 | */
43 | String replace(String strToReplace, final String format);
44 | }
45 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/java/io/github/selcukes/databind/tests/CreateDataFileWithAgsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.tests;
18 |
19 | import io.github.selcukes.collections.Clocks;
20 | import io.github.selcukes.databind.DataMapper;
21 | import io.github.selcukes.databind.annotation.DataFile;
22 | import lombok.Data;
23 | import org.testng.annotations.Test;
24 |
25 | public class CreateDataFileWithAgsTest {
26 | private static final String TIMESTAMP_FORMAT = "MM/dd/yyyy hh:mm:ss";
27 |
28 | @Test(enabled = false)
29 | public void dataTest() {
30 | String currentDataTime = Clocks.dateTime(TIMESTAMP_FORMAT);
31 | Resolve resolve = new Resolve();
32 | resolve.setChromeVersion("10.11.213");
33 | resolve.setDataTime(currentDataTime);
34 | DataMapper.write(resolve);
35 | }
36 |
37 | @Data
38 | @DataFile(folderPath = "E:/New folder/WebDrivers")
39 | static class Resolve {
40 | String chromeVersion;
41 | String dataTime;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/java/io/github/selcukes/databind/tests/ExcelWriterTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.tests;
18 |
19 | import io.github.selcukes.collections.DataTable;
20 | import io.github.selcukes.collections.Resources;
21 | import io.github.selcukes.databind.excel.ExcelMapper;
22 | import org.testng.annotations.Test;
23 |
24 | import java.util.LinkedHashMap;
25 | import java.util.Map;
26 |
27 | import static org.testng.Assert.assertEquals;
28 |
29 | public class ExcelWriterTest {
30 | @Test
31 | public void excelWrite() {
32 | DataTable input = DataTable.of(
33 | new LinkedHashMap<>(Map.of("ID", 1, "Name", "John Doe", "Age", 30, "IsEmployed", false)),
34 | new LinkedHashMap<>(Map.of("ID", 2, "Name", "Jane Smith", "Age", 40, "IsEmployed", false)),
35 | new LinkedHashMap<>(Map.of("ID", 3, "Name", "Tom", "Age", 35, "IsEmployed", false)));
36 |
37 | String fileName = Resources.ofTest("output.xlsx").toString();
38 | String sheetName = "Sheet1";
39 | ExcelMapper.write(input, fileName, sheetName);
40 | var output = ExcelMapper.parse(fileName, sheetName);
41 | assertEquals(output.toString(), input.toString());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/java/io/github/selcukes/databind/tests/JsonUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.tests;
18 |
19 | import io.github.selcukes.databind.utils.JsonUtils;
20 | import org.testng.annotations.Test;
21 |
22 | import java.util.LinkedHashMap;
23 |
24 | import static org.testng.Assert.assertEquals;
25 |
26 | public class JsonUtilsTest {
27 |
28 | @Test
29 | public void jsonTest() {
30 | var map = new LinkedHashMap<>();
31 | map.put("a", "1");
32 | map.put("b", "2");
33 | map.put("c", "3");
34 | String expected = "{\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}";
35 | assertEquals(JsonUtils.toJson(map), expected);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/java/io/github/selcukes/databind/tests/ListStringConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.databind.tests;
18 |
19 | import io.github.selcukes.databind.converters.DefaultConverter;
20 |
21 | import java.util.Arrays;
22 | import java.util.List;
23 |
24 | public class ListStringConverter extends DefaultConverter> {
25 | @Override
26 | public List convert(final String value) {
27 | return Arrays.asList(value.split(","));
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/java/io/github/selcukes/databind/tests/UpdateDataFileTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.databind.tests;
20 |
21 | import io.github.selcukes.databind.DataMapper;
22 | import io.github.selcukes.databind.annotation.DataFile;
23 | import lombok.Data;
24 | import lombok.SneakyThrows;
25 | import org.testng.annotations.Test;
26 |
27 | import java.util.Map;
28 | import java.util.UUID;
29 |
30 | public class UpdateDataFileTest {
31 | @SneakyThrows
32 | @Test
33 | public void updateDataFile() {
34 | UUID uuid = UUID.randomUUID();
35 | TestSample testSample = DataMapper.parse(TestSample.class);
36 | testSample.getUsers().get("user1").put("password", uuid.toString());
37 | DataMapper.write(testSample);
38 | }
39 |
40 | @Data
41 | @DataFile(fileName = "test_sample.yml")
42 | static class TestSample {
43 | Map> users;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/CustomerInfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2019-03-06T07:32:26
4 | CREATE
5 | 1258D20190306T073226
6 | SCD_SENT
7 |
8 | Central Pacific Bank
9 | 2100-31-12
10 |
11 | 125 Street
12 |
13 | Des moines
14 | USA
15 | IA
16 | 50303
17 |
18 |
19 |
20 | 1256
21 | test@test.com
22 | Ramesh
23 | Babu
24 | +15168978352
25 | Treasury
26 | +19087253123
27 |
28 |
29 | 5689
30 | test@test.com
31 | Mohan
32 | Babu
33 | +19011978123
34 | Treasury
35 | +19011253456
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/TestData.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selcukes/selcukes-java/99d3a807e3992370a8ca1a00a4ea2d8e1cece8b3/selcukes-databind/src/test/resources/TestData.xlsx
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/employee.csv:
--------------------------------------------------------------------------------
1 | ID,Name ,Email ,Phone ,Country,Address,Mojo
2 | ,Rajeev Kumar Singh ,rajeevs@example.com,+91-9999999999,India, "12,Hello Street"
3 | ,Sachin Tendulkar,sachin@example.com,+91-9999999998,India,"34,é Street"
4 | ,Barak Obama,barak.obama@example.com,+1-1111111111,United States,
5 | ,Donald Trump,donald.trump@example.com,+1-2222222222,United States,"56,Rb's Street"
6 | , ,,,,,
7 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/test_config.properties:
--------------------------------------------------------------------------------
1 | userName=Ramesh
2 | password=cred
3 | isTest=true
4 | osName=${os.name}
5 | date=${date}
6 | sampleDate=12/12/2022
7 | test.count=50
8 | elements=ele1,ele2
9 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/test_sample.yml:
--------------------------------------------------------------------------------
1 | ---
2 | users:
3 | user1:
4 | username: "junk"
5 | password: "d9fb64d7-4c05-444b-8c8f-dd012cbaed33"
6 | user2:
7 | username: "spam"
8 | password: "40aafad2-1d24-4d6c-85e2-b7630dc17c57"
9 |
--------------------------------------------------------------------------------
/selcukes-databind/src/test/resources/test_users.json:
--------------------------------------------------------------------------------
1 | {
2 | "users": [
3 | {
4 | "username": "junk",
5 | "password": "7e49fab8-550b-44b2-959d-e991e897dff9"
6 | },
7 | {
8 | "username": "spam",
9 | "password": "42e25964-e373-453f-b130-8e156ea779ec"
10 | }
11 | ]
12 | }
--------------------------------------------------------------------------------
/selcukes-excel-runner/README.md:
--------------------------------------------------------------------------------
1 | # Selcukes Excel Runner
2 |
3 | To use add the `selcukes-excel-runner` dependency to your pom.xml:
4 |
5 | ```xml
6 |
7 | [...]
8 |
9 | io.github.selcukes
10 | selcukes-excel-runner
11 | ${selcukes-excel-runner.version}
12 |
13 | [...]
14 |
15 |
16 | ```
17 |
18 | Refer [wiki](https://github.com/selcukes/selcukes-java/wiki/Selcukes-Excel-Runner) for documentation
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/main/java/io/github/selcukes/excel/ExcelDataFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel;
18 |
19 | import io.github.selcukes.collections.StringHelper;
20 | import io.github.selcukes.commons.config.ConfigFactory;
21 | import io.github.selcukes.commons.helper.Singleton;
22 |
23 | public class ExcelDataFactory {
24 | private ExcelDataFactory() {
25 | // Ignore this
26 | }
27 |
28 | /**
29 | * Returns an instance of the ExcelDataProvider implementation based on the
30 | * configuration specified in the application properties file.
31 | *
32 | * @return an instance of SingleExcelData or MultiExcelData, depending on
33 | * the configuration
34 | */
35 | public static ExcelDataProvider getInstance() {
36 | String suiteFile = ConfigFactory.getConfig().getExcel().get("suiteFile");
37 | return StringHelper.isEmpty(suiteFile) ? Singleton.instanceOf(SingleExcelData.class)
38 | : Singleton.instanceOf(MultiExcelData.class);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/main/java/io/github/selcukes/excel/ScenarioContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel;
18 |
19 | import io.cucumber.java.Scenario;
20 | import lombok.experimental.UtilityClass;
21 |
22 | @UtilityClass
23 | public class ScenarioContext {
24 | private static final ThreadLocal testName = new InheritableThreadLocal<>();
25 |
26 | private String getFeatureName(Scenario scenario) {
27 | String featureName = scenario.getUri().getPath();
28 | featureName = featureName.substring(featureName.lastIndexOf("/") + 1, featureName.indexOf("."));
29 | return featureName;
30 | }
31 |
32 | public void setTestName(Scenario scenario) {
33 | testName.set(getFeatureName(scenario) + "::" + scenario.getName());
34 | }
35 |
36 | public String getTestName() {
37 | return testName.get();
38 | }
39 |
40 | public void removeTestName() {
41 | testName.remove();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/java/io/github/selcukes/excel/TestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel;
18 |
19 | public class TestRunner extends ExcelTestRunner {
20 | }
21 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/java/io/github/selcukes/excel/page/CommonPage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel.page;
18 |
19 | import io.github.selcukes.excel.ExcelDataFactory;
20 |
21 | import java.util.Map;
22 |
23 | public class CommonPage {
24 |
25 | public Map getScenarioData() {
26 | return ExcelDataFactory.getInstance().getScenarioData();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/java/io/github/selcukes/excel/steps/Hooks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel.steps;
18 |
19 | import io.cucumber.java.After;
20 | import io.cucumber.java.Before;
21 | import io.cucumber.java.Scenario;
22 | import io.github.selcukes.excel.ScenarioContext;
23 |
24 | public class Hooks {
25 |
26 | @Before
27 | public void beforeTest(Scenario scenario) {
28 | ScenarioContext.setTestName(scenario);
29 | }
30 |
31 | @After
32 | public void afterTest(Scenario scenario) {
33 | ScenarioContext.removeTestName();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/java/io/github/selcukes/excel/steps/MySteps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.excel.steps;
18 |
19 | import io.cucumber.java.en.Given;
20 | import io.cucumber.java.en.Then;
21 | import io.github.selcukes.excel.page.CommonPage;
22 | import lombok.CustomLog;
23 |
24 | @CustomLog
25 | public class MySteps {
26 | private final CommonPage commonPage;
27 |
28 | public MySteps(CommonPage commonPage) {
29 | this.commonPage = commonPage;
30 | }
31 |
32 | @Given("I open {} page")
33 | public void openPage(String page) {
34 | logger.info(() -> page);
35 |
36 | }
37 |
38 | @Then("I see {string} in the title")
39 | public void title(String page) {
40 | logger.info(() -> page);
41 | }
42 |
43 | @Given("I kinda open {} page")
44 | public void kinda(String page) {
45 | logger.info(() -> page);
46 | }
47 |
48 | @Then("I am very happy")
49 | public void happy() {
50 | commonPage.getScenarioData()
51 | .forEach((k, v) -> logger.info(() -> String.format("Key: [%s] Values: [%s]%n", k, v)));
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/Google.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selcukes/selcukes-java/99d3a807e3992370a8ca1a00a4ea2d8e1cece8b3/selcukes-excel-runner/src/test/resources/Google.xlsx
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/TestData.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selcukes/selcukes-java/99d3a807e3992370a8ca1a00a4ea2d8e1cece8b3/selcukes-excel-runner/src/test/resources/TestData.xlsx
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/TestSuite.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selcukes/selcukes-java/99d3a807e3992370a8ca1a00a4ea2d8e1cece8b3/selcukes-excel-runner/src/test/resources/TestSuite.xlsx
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/Yahoo.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/selcukes/selcukes-java/99d3a807e3992370a8ca1a00a4ea2d8e1cece8b3/selcukes-excel-runner/src/test/resources/Yahoo.xlsx
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/features/Google.feature:
--------------------------------------------------------------------------------
1 | Feature: Google
2 |
3 | Scenario Outline: Google Login -
4 | Given I open Google page
5 | Then I see "Google" in the title
6 | Examples:
7 | | Scenario |
8 | | Example 1 |
9 | | Example 2 |
10 |
11 | Scenario: Different kind of opening
12 | Given I kinda open Google page
13 | Then I am very happy
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/features/Yahoo.feature:
--------------------------------------------------------------------------------
1 | Feature: Yahoo
2 |
3 | Scenario Outline: Yahoo Login -
4 | Given I open Yahoo page
5 | Then I see "Yahoo" in the title
6 | Examples:
7 | | Scenario |
8 | | Example 1 |
9 | | Example 2 |
10 | | Example 3 |
11 |
12 | Scenario: Yahoo Home
13 | Given I kinda open Yahoo page
14 | Then I am very happy
15 |
--------------------------------------------------------------------------------
/selcukes-excel-runner/src/test/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | # Selcukes Environment Properties
2 | ---
3 | projectName: Selcukes
4 | env: Dev
5 | proxy: false
6 | baseUrl:
7 | excel:
8 | runner: true
9 | suiteFile: "TestSuite.xlsx"
10 | dataFile: "TestData.xlsx"
11 | suiteName: "Smoke"
12 | cucumber:
13 | module:
14 | features: src/test/resources/features
15 | glue: io.github.selcukes.excel.steps
16 | tags:
17 | plugin:
18 | reports:
19 | emailReport: true
20 | htmlReport: true
21 | path: target
22 | fileName: TestReport
23 | timestamp: false
24 |
--------------------------------------------------------------------------------
/selcukes-extent-reports/README.md:
--------------------------------------------------------------------------------
1 | # Selcukes Extent Report
2 |
3 | To use add the `selcukes-extent-reports` dependency to your pom.xml:
4 |
5 | ```xml
6 |
7 | [...]
8 |
9 | io.github.selcukes
10 | selcukes-extent-reports
11 | ${selcukes-extent-reports.version}
12 |
13 | [...]
14 |
15 |
16 | ```
17 |
18 | Refer [wiki](https://github.com/selcukes/selcukes-java/wiki/Selcukes-Extent-Report) for documentation
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/test/java/io/github/selcukes/extent/report/tests/TestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.extent.report.tests;
18 |
19 | import io.github.selcukes.testng.SelcukesTestNGRunner;
20 |
21 | public class TestRunner extends SelcukesTestNGRunner {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/test/java/io/github/selcukes/extent/report/tests/steps/CalculatorSteps.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.extent.report.tests.steps;
20 |
21 | import io.cucumber.java.en.Given;
22 | import io.cucumber.java.en.Then;
23 | import io.cucumber.java.en.When;
24 | import io.github.selcukes.commons.Await;
25 | import io.github.selcukes.extent.report.tests.pages.Calculator;
26 | import org.testng.Assert;
27 |
28 | public class CalculatorSteps {
29 | private Calculator calc;
30 |
31 | @Given("a calculator I just turned on")
32 | public void setup() {
33 | calc = new Calculator();
34 | }
35 |
36 | @When("I add {int} and {int}")
37 | public void add(int arg1, int arg2) {
38 | calc.push(arg1);
39 | calc.push(arg2);
40 | calc.push("+");
41 | }
42 |
43 | @When("I subtract {int} to {int}")
44 | public void subtract(int arg1, int arg2) {
45 | calc.push(arg1);
46 | calc.push(arg2);
47 | calc.push("-");
48 | }
49 |
50 | @Then("the result is {double}")
51 | public void theResultIs(double expected) {
52 | Assert.assertEquals(expected, calc.value());
53 | Await.until(5);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/test/java/io/github/selcukes/extent/report/tests/steps/ReporterHooks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.extent.report.tests.steps;
18 |
19 | import io.cucumber.java.After;
20 | import io.cucumber.java.AfterStep;
21 | import io.cucumber.java.Before;
22 | import io.cucumber.java.BeforeStep;
23 | import io.cucumber.java.Scenario;
24 | import lombok.CustomLog;
25 |
26 | @CustomLog
27 | public class ReporterHooks {
28 |
29 | @Before
30 | public void beforeTest(Scenario scenario) {
31 |
32 | // .initSnapshot(driver); //Initialise Full page screenshot
33 | logger.info(() -> "Starting Scenario .." + scenario.getName());
34 | }
35 |
36 | @BeforeStep
37 | public void beforeStep() {
38 | logger.info(() -> "Before Step");
39 |
40 | }
41 |
42 | @AfterStep
43 | public void afterStep() {
44 |
45 | // getReport().attachScreenshot(); //Attach Full page screenshot
46 |
47 | }
48 |
49 | @After
50 | public void afterTest(Scenario scenario) {
51 | logger.info(() -> "Completed Scenario .." + scenario.getName());
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/test/resources/calculator.feature:
--------------------------------------------------------------------------------
1 | Feature: Basic Arithmetic
2 |
3 | Background: A Calculator
4 | Given a calculator I just turned on
5 |
6 | Scenario: Addition
7 | When I add 4 and 5
8 | Then the result is 9
9 |
10 | Scenario: Subtraction
11 | When I subtract 7 to 2
12 | Then the result is 5
13 |
14 | @parallel
15 | Scenario Outline: Sum of and
16 | When I add and
17 | Then the result is
18 |
19 | Examples: Single digits
20 | | arg1 | arg2 | sum |
21 | | 1 | 2 | 3 |
22 | | 3 | 7 | 10 |
23 | | 6 | 8 | 14 |
24 | | 8 | 7 | 15 |
25 |
--------------------------------------------------------------------------------
/selcukes-extent-reports/src/test/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | # Selcukes Environment Properties
2 | ---
3 | projectName: Selcukes
4 | env: Dev
5 | proxy: false
6 | baseUrl:
7 | cucumber:
8 | module:
9 | features: src/test/resources/
10 | glue: io.github.selcukes.extent.report.tests.steps
11 | tags:
12 | plugin:
13 | reports:
14 | emailReport: true
15 | htmlReport: true
16 | path: target
17 | fileName: TestReport
18 | timestamp: false
--------------------------------------------------------------------------------
/selcukes-junit/src/main/java/io/github/selcukes/junit/Selcukes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.junit;
18 |
19 | import org.junit.platform.commons.annotation.Testable;
20 |
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | @Retention(RetentionPolicy.RUNTIME)
27 | @Target({ ElementType.TYPE })
28 | @Testable
29 | public @interface Selcukes {
30 | }
31 |
--------------------------------------------------------------------------------
/selcukes-junit/src/main/java/io/github/selcukes/junit/listeners/SuiteListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.junit.listeners;
18 |
19 | import io.github.selcukes.commons.fixture.SelcukesFixture;
20 | import io.github.selcukes.commons.properties.SelcukesRuntime;
21 | import lombok.CustomLog;
22 | import org.junit.platform.launcher.LauncherDiscoveryListener;
23 | import org.junit.platform.launcher.LauncherDiscoveryRequest;
24 |
25 | @CustomLog
26 | public class SuiteListener implements LauncherDiscoveryListener {
27 |
28 | @Override
29 | public void launcherDiscoveryStarted(LauncherDiscoveryRequest request) {
30 | SelcukesFixture.setValidator("org.junit.jupiter.api.Assertions");
31 | SelcukesRuntime.loadOptions();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-junit/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherDiscoveryListener:
--------------------------------------------------------------------------------
1 | io.github.selcukes.junit.listeners.SuiteListener
--------------------------------------------------------------------------------
/selcukes-junit/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener:
--------------------------------------------------------------------------------
1 | io.github.selcukes.junit.listeners.TestListener
--------------------------------------------------------------------------------
/selcukes-junit/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-junit/src/test/java/io/github/selcukes/junit/tests/SampleJunitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.junit.tests;
18 |
19 | import lombok.CustomLog;
20 | import org.junit.jupiter.api.Test;
21 |
22 | @CustomLog
23 | class SampleJunitTest {
24 | @Test
25 | void sampleTest() {
26 | logger.info(() -> "This is sample test");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/selcukes-junit/src/test/java/io/github/selcukes/junit/tests/Steps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.junit.tests;
18 |
19 | import io.cucumber.java.en.Then;
20 | import io.cucumber.java.en.When;
21 | import lombok.CustomLog;
22 |
23 | @CustomLog
24 | public class Steps {
25 | @When("the Maker starts a game")
26 | public void theMakerStartsAGame() {
27 | logger.info(() -> "the Maker starts a game");
28 |
29 | }
30 |
31 | @Then("the Maker waits for a Breaker to join")
32 | public void theMakerWaitsForABreakerToJoin() {
33 | logger.info(() -> "the Maker waits for a Breaker to join");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/selcukes-junit/src/test/java/io/github/selcukes/junit/tests/TestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.junit.tests;
18 |
19 | import org.junit.platform.suite.api.IncludeEngines;
20 | import org.junit.platform.suite.api.SelectClasses;
21 | import org.junit.platform.suite.api.Suite;
22 |
23 | @Suite
24 | @IncludeEngines({ "junit-jupiter" }) // This will ensure cucumber tests not
25 | // executed twice.
26 | @SelectClasses(SampleJunitTest.class)
27 | class TestRunner {
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/selcukes-junit/src/test/resources/features/google/sample.feature:
--------------------------------------------------------------------------------
1 | Feature: Sample Guess the word
2 |
3 | @ex
4 | Scenario: Google starts a game
5 | When the Maker starts a game
6 | Then the Maker waits for a Breaker to join
7 |
8 | @ex1
9 | Scenario: Google starts a game
10 | When the Maker starts a game
--------------------------------------------------------------------------------
/selcukes-junit/src/test/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | # Selcukes Environment Properties
2 | ---
3 | projectName: Selcukes
4 | env: Dev
5 | proxy: false
6 | baseUrl:
7 | cucumber:
8 | module: google
9 | features: src/test/resources/features/${module}
10 | glue: io.github.selcukes.junit.tests
11 | tags:
12 | plugin:
13 | reports:
14 | emailReport: false
15 | htmlReport: true
16 | path: target
17 | fileName: TestReport
18 | timestamp: false
19 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/IncomingWebHookRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier;
18 |
19 | import io.github.selcukes.commons.http.WebClient;
20 |
21 | public interface IncomingWebHookRequest {
22 | static WebClient forUrl(String webHookUrl) {
23 | return new WebClient(webHookUrl);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/Notifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier;
18 |
19 | public interface Notifier {
20 | Notifier scenarioName(String title);
21 |
22 | Notifier scenarioStatus(String status);
23 |
24 | Notifier stepDetails(String message);
25 |
26 | Notifier errorMessage(String error);
27 |
28 | Notifier path(String path);
29 |
30 | void pushNotification();
31 | }
32 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/NotifierHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.notifier;
20 |
21 | import lombok.experimental.UtilityClass;
22 |
23 | @UtilityClass
24 | public class NotifierHelper {
25 | public String getThemeColor(String stepStatus) {
26 | String messageColor = null;
27 | switch (stepStatus) {
28 | case "FAILED":
29 | messageColor = "FF0000"; // Red
30 | break;
31 | case "PASSED":
32 | messageColor = "36a64f"; // Green
33 | break;
34 | case "SKIPPED":
35 | messageColor = "FFA500"; // Orange
36 | break;
37 | default:
38 | }
39 | return messageColor;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/enums/NotifierEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.notifier.enums;
20 |
21 | import lombok.AllArgsConstructor;
22 | import lombok.Getter;
23 |
24 | @Getter
25 | @AllArgsConstructor
26 | public enum NotifierEnum {
27 | PRETEXT("Selcukes Automation Report"),
28 | CALL_BACK("Callback"),
29 | AUTHOR("Ramesh"),
30 | TECHYWORKS("https://techyworks.blogspot.com/"),
31 | FOOTER_TEXT("Test Start Time"),
32 | FOOTER_ICON("https://techyworks.blogspot.com/favicon.ico"),
33 | WEB_HOOKS_URL("https://hooks.slack.com/services/"),
34 | SLACK_API_URL("https://slack.com/api/files.upload?token="),
35 | PROJECT("Project"),
36 | ENVIRONMENT("Environment"),
37 | ATTACHMENT("Attachments"),
38 | MESSAGE_CARD("MessageCard"),
39 | TIME_STAMP("Time Stamp"),
40 | EXCEPTION("Exception");
41 | final String value;
42 | }
43 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/enums/NotifierType.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.notifier.enums;
20 |
21 | public enum NotifierType {
22 | SLACK,
23 | TEAMS
24 | }
25 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/slack/Field.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.slack;
18 |
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import lombok.Builder;
21 |
22 | import java.io.Serializable;
23 |
24 | @Builder
25 | record Field(String title, String value, @JsonProperty("short") Boolean shortValue) implements Serializable {
26 | }
27 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/slack/Slack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.slack;
18 |
19 | import io.github.selcukes.notifier.AbstractNotifier;
20 | import io.github.selcukes.notifier.Notifier;
21 |
22 | public class Slack extends AbstractNotifier {
23 |
24 | @Override
25 | public Notifier pushNotification(
26 | String scenarioTitle, String scenarioStatus, String message, String error, String screenshotPath
27 | ) {
28 | SlackMessageBuilder slackMessageBuilder = new SlackMessageBuilder();
29 | slackMessageBuilder.sendMessage(scenarioTitle, scenarioStatus, error, screenshotPath);
30 | SlackUploader slackUploader = new SlackUploader();
31 | slackUploader.uploadFile(screenshotPath);
32 | return this;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/slack/SlackFileUploader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.slack;
18 |
19 | import lombok.AllArgsConstructor;
20 | import lombok.Builder;
21 | import lombok.Data;
22 | import lombok.NoArgsConstructor;
23 |
24 | @Data
25 | @AllArgsConstructor
26 | @NoArgsConstructor
27 | @Builder
28 | public class SlackFileUploader {
29 | private String channel;
30 | private String token;
31 | private String filePath;
32 | private String fileName;
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/slack/SlackMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.slack;
18 |
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import lombok.AllArgsConstructor;
21 | import lombok.Builder;
22 | import lombok.Getter;
23 | import lombok.Setter;
24 |
25 | import java.io.Serializable;
26 | import java.util.List;
27 |
28 | @AllArgsConstructor
29 | @Builder(builderClassName = "Builder")
30 | @Getter
31 | @Setter
32 | public class SlackMessage implements Serializable {
33 | private String username;
34 | private String text;
35 | @JsonProperty("icon_url")
36 | private String iconUrl;
37 | @JsonProperty("icon_emoji")
38 | private String iconEmoji;
39 | private String channel;
40 | private List attachments;
41 | }
42 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/slack/SlackUploader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.slack;
18 |
19 | import io.github.selcukes.commons.config.ConfigFactory;
20 | import io.github.selcukes.notifier.IncomingWebHookRequest;
21 | import io.github.selcukes.notifier.enums.NotifierEnum;
22 |
23 | import java.nio.file.Paths;
24 |
25 | public class SlackUploader {
26 |
27 | public void uploadFile(String filePath) {
28 | SlackFileUploader slackFileUploader = SlackFileUploader.builder()
29 | .channel(ConfigFactory.getConfig().getNotifier().getChannel())
30 | .token(ConfigFactory.getConfig().getNotifier().getApiToken())
31 | .filePath(filePath)
32 | .fileName("Sample")
33 | .build();
34 |
35 | String url = String.join("",
36 | NotifierEnum.SLACK_API_URL.getValue(),
37 | slackFileUploader.getToken(),
38 | "&channels=",
39 | slackFileUploader.getChannel(),
40 | "&pretty=1");
41 | IncomingWebHookRequest.forUrl(url)
42 | .post(Paths.get(slackFileUploader.getFilePath()));
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/teams/Field.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.teams;
18 |
19 | import lombok.Builder;
20 | import lombok.Data;
21 |
22 | @Data
23 | @Builder
24 | public class Field {
25 | private final String name;
26 | private final String value;
27 | }
28 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/teams/Images.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.teams;
18 |
19 | import lombok.Builder;
20 | import lombok.Data;
21 |
22 | @Data
23 | @Builder
24 | public class Images {
25 | private String image;
26 | }
27 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/teams/MicrosoftTeams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.teams;
18 |
19 | import io.github.selcukes.notifier.AbstractNotifier;
20 | import io.github.selcukes.notifier.Notifier;
21 |
22 | public class MicrosoftTeams extends AbstractNotifier {
23 |
24 | @Override
25 | public Notifier pushNotification(
26 | String scenarioTitle, String scenarioStatus, String message, String error, String screenshotPath
27 | ) {
28 | MicrosoftTeamsBuilder teamsBuilder = new MicrosoftTeamsBuilder();
29 | teamsBuilder.sendMessage(scenarioTitle, scenarioStatus, message, error, screenshotPath);
30 | return this;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/teams/MicrosoftTeamsCard.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.teams;
18 |
19 | import com.fasterxml.jackson.annotation.JsonInclude;
20 | import com.fasterxml.jackson.annotation.JsonProperty;
21 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
22 | import lombok.Builder;
23 | import lombok.Data;
24 |
25 | import java.util.List;
26 |
27 | @Data
28 | @Builder
29 | @JsonInclude(JsonInclude.Include.NON_NULL)
30 | @JsonPropertyOrder({ "@context", "@type", "themeColor", "title", "text" })
31 | public class MicrosoftTeamsCard {
32 |
33 | @JsonProperty("sections")
34 | private final List sections;
35 | @Builder.Default
36 | @JsonProperty("@context")
37 | private String context = "https://schema.org/extensions";
38 | @JsonProperty("@type")
39 | private String type;
40 | @JsonProperty("themeColor")
41 | private String themeColor;
42 | @JsonProperty("title")
43 | private String title;
44 | @JsonProperty("text")
45 | private String text;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/java/io/github/selcukes/notifier/teams/Section.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.teams;
18 |
19 | import lombok.Builder;
20 | import lombok.Data;
21 |
22 | import java.util.List;
23 |
24 | @Data
25 | @Builder
26 | public class Section {
27 | private final List facts;
28 | private final String activityTitle;
29 | private final String activitySubtitle;
30 | private final String activityText;
31 | private final String activityImage;
32 | private final List images;
33 | @Builder.Default
34 | private boolean markdown = true;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.devtools.level: SEVERE
10 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
11 |
12 | # Default file output is in user's home directory.
13 | java.util.logging.FileHandler.pattern: selcukes.log
14 | java.util.logging.FileHandler.limit: 50000
15 | java.util.logging.FileHandler.count: 1
16 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
17 | java.util.logging.FileHandler.level: FINE
18 |
19 | # Limit the message that are printed on the console to INFO and above.
20 | java.util.logging.ConsoleHandler.level: FINE
21 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
22 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-notifier/src/main/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | # Selcukes Environment Properties
2 | ---
3 | projectName: Selcukes Automation Report
4 | env: QA01
5 | notifier:
6 | notification: false
7 | type: teams
8 | webhookToken: WEBXXX
9 | apiToken: APIXXXX
10 | channel: selcukes
11 | authorIcon: https://avatars0.githubusercontent.com/u/2510294?s=400&u=5d6412ba1dd13052992ff66317ae28d007a971d3&v=4
12 | mail:
13 | host: smtp.gmail.com
14 | port: 465
15 | username: test@gmail.com
16 | password: rkxynldqlpxdxota
17 | from: test@gmail.com
18 | to: test@gmail.com
19 | cc: test@gmail.com
20 | bcc: test@gmail.com
21 |
22 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/test/java/io/github/selcukes/notifier/tests/EmailTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.tests;
18 |
19 | import io.github.selcukes.notifier.NotifierFactory;
20 | import org.testng.annotations.Test;
21 |
22 | public class EmailTest {
23 | @Test(enabled = false)
24 | public void mailTest() {
25 | String subject = "Test Report";
26 | String body = "This is the body of the test report.";
27 | NotifierFactory.emailNotifier()
28 | .sendMail(subject, body, "src/test/resources/employee.csv");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/test/java/io/github/selcukes/notifier/tests/NotifierTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.notifier.tests;
18 |
19 | import io.github.selcukes.notifier.NotifierFactory;
20 | import org.testng.annotations.Test;
21 |
22 | public class NotifierTest {
23 | @Test(enabled = false)
24 | public void testNotifications() {
25 | NotifierFactory.getNotifier()
26 | .scenarioName("This is sample scenario")
27 | .scenarioStatus("FAILED")
28 | .stepDetails("This is sample test step")
29 | .errorMessage("NullPointerException")
30 | .path("")
31 | .pushNotification();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-notifier/src/test/resources/employee.csv:
--------------------------------------------------------------------------------
1 | ID,Name ,Email ,Phone ,Country,Address,Mojo
2 | ,Rajeev Kumar Singh ,rajeevs@example.com,+91-9999999999,India, "12,Hello Street"
3 | ,Sachin Tendulkar,sachin@example.com,+91-9999999998,India,"34,é Street"
4 | ,Barak Obama,barak.obama@example.com,+1-1111111111,United States,
5 | ,Donald Trump,donald.trump@example.com,+1-2222222222,United States,"56,Rb's Street"
6 | , ,,,,,
7 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/java/io/github/selcukes/reports/cucumber/CucumberService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.cucumber;
18 |
19 | import io.cucumber.plugin.event.Status;
20 |
21 | public interface CucumberService {
22 | void beforeTest();
23 |
24 | void beforeScenario();
25 |
26 | void beforeStep();
27 |
28 | void afterStep(String step, boolean status);
29 |
30 | void afterScenario(String scenario, Status status);
31 |
32 | void afterTest();
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/java/io/github/selcukes/reports/cucumber/EventFiringCucumber.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.cucumber;
18 |
19 | import lombok.experimental.UtilityClass;
20 |
21 | @UtilityClass
22 | public class EventFiringCucumber {
23 | private CucumberService regService;
24 |
25 | public void register(CucumberService service) {
26 | regService = service;
27 | }
28 |
29 | public CucumberService getService() {
30 | return (regService == null) ? new CucumberAdapter() : regService;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/java/io/github/selcukes/reports/cucumber/LiveReportHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.cucumber;
18 |
19 | import io.github.selcukes.commons.http.WebClient;
20 | import io.github.selcukes.commons.http.WebResponse;
21 | import io.github.selcukes.databind.utils.JsonUtils;
22 | import lombok.CustomLog;
23 | import lombok.SneakyThrows;
24 | import lombok.experimental.UtilityClass;
25 |
26 | @CustomLog
27 | @UtilityClass
28 | public class LiveReportHelper {
29 | @SneakyThrows
30 | public void publishResults(Object object, String key) {
31 | logger.debug(() -> JsonUtils.toPrettyJson(object));
32 | String url = "http://localhost:9200/%s/results";
33 | WebClient client = new WebClient(String.format(url, key));
34 | WebResponse response = client.post(object);
35 | logger.debug(response::body);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/java/io/github/selcukes/reports/enums/TestType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.enums;
18 |
19 | public enum TestType {
20 | CUCUMBER,
21 | TESTNG,
22 | JUNIT
23 | }
24 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/java/io/github/selcukes/reports/screen/ScreenPlayBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.screen;
18 |
19 | import io.github.selcukes.commons.fixture.DriverFixture;
20 | import lombok.experimental.UtilityClass;
21 | import org.openqa.selenium.WebDriver;
22 |
23 | @UtilityClass
24 | public class ScreenPlayBuilder {
25 |
26 | public ScreenPlay getScreenPlay(WebDriver driver) {
27 | return new ScreenPlayImpl(driver);
28 | }
29 |
30 | public ScreenPlay getScreenPlay() {
31 | return new ScreenPlayImpl((WebDriver) DriverFixture.getDriverFixture());
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/selcukes-reports/src/main/resources/META-INF/services/io.github.selcukes.commons.listener.TestLifecycleListener:
--------------------------------------------------------------------------------
1 | io.github.selcukes.reports.listeners.ReportServiceProvider
--------------------------------------------------------------------------------
/selcukes-reports/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-reports/src/test/java/io/github/selcukes/reports/tests/TestRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.tests;
18 |
19 | import io.github.selcukes.testng.SelcukesTestNGRunner;
20 |
21 | public class TestRunner extends SelcukesTestNGRunner {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/selcukes-reports/src/test/java/io/github/selcukes/reports/tests/steps/CalculatorSteps.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (c) Ramesh Babu Prudhvi.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | package io.github.selcukes.reports.tests.steps;
20 |
21 | import io.cucumber.java.en.Given;
22 | import io.cucumber.java.en.Then;
23 | import io.cucumber.java.en.When;
24 | import io.github.selcukes.commons.Await;
25 | import io.github.selcukes.reports.tests.pages.Calculator;
26 | import org.testng.Assert;
27 |
28 | public class CalculatorSteps {
29 | private Calculator calc;
30 |
31 | @Given("a calculator I just turned on")
32 | public void setup() {
33 | calc = new Calculator();
34 | }
35 |
36 | @When("I add {int} and {int}")
37 | public void add(int arg1, int arg2) {
38 | calc.push(arg1);
39 | calc.push(arg2);
40 | calc.push("+");
41 | }
42 |
43 | @When("I subtract {int} to {int}")
44 | public void subtract(int arg1, int arg2) {
45 | calc.push(arg1);
46 | calc.push(arg2);
47 | calc.push("-");
48 | }
49 |
50 | @Then("the result is {double}")
51 | public void theResultIs(double expected) {
52 | Assert.assertEquals(expected, calc.value());
53 | Await.until(2);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/selcukes-reports/src/test/java/io/github/selcukes/reports/tests/steps/ReporterHooks.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.reports.tests.steps;
18 |
19 | import io.cucumber.java.After;
20 | import io.cucumber.java.AfterStep;
21 | import io.cucumber.java.Before;
22 | import io.cucumber.java.BeforeStep;
23 | import io.cucumber.java.Scenario;
24 | import lombok.CustomLog;
25 |
26 | @CustomLog
27 | public class ReporterHooks {
28 |
29 | @Before
30 | public void beforeTest(Scenario scenario) {
31 |
32 | logger.info(() -> "Starting Scenario .." + scenario.getName());
33 | }
34 |
35 | @BeforeStep
36 | public void beforeStep() {
37 | logger.info(() -> "Before Step");
38 |
39 | }
40 |
41 | @AfterStep
42 | public void afterStep() {
43 | logger.info(() -> "After Step");
44 | }
45 |
46 | @After
47 | public void afterTest(Scenario scenario) {
48 | logger.info(() -> "Completed Scenario .." + scenario.getName());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/selcukes-reports/src/test/resources/calculator.feature:
--------------------------------------------------------------------------------
1 | Feature: Basic Arithmetic
2 |
3 | Background: A Calculator
4 | Given a calculator I just turned on
5 |
6 | Scenario: Addition
7 | When I add 4 and 5
8 | Then the result is 9
9 |
10 | Scenario: Subtraction
11 | When I subtract 7 to 2
12 | Then the result is 5
13 |
14 | @abc
15 | Scenario Outline: Several additions
16 | When I add and
17 | Then the result is
18 |
19 | Examples: Single digits
20 | | a | b | c |
21 | | 1 | 2 | 3 |
22 | | 3 | 7 | 10 |
23 | | 6 | 8 | 14 |
24 | | 8 | 7 | 15 |
--------------------------------------------------------------------------------
/selcukes-reports/src/test/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | projectName: Selcukes
2 | env: Dev
3 | proxy: false
4 | baseUrl:
5 | excel:
6 | runner: false
7 | fileName: src/test/resources/TestData.xlsx
8 | suiteName: "Smoke"
9 | cucumber:
10 | module:
11 | features: src/test/resources/
12 | glue: io.github.selcukes.reports.tests.steps
13 | tags:
14 | plugin:
15 | web:
16 | remote: true
17 | browser: CHROME
18 | headLess: true
19 | serviceUrl: "http://127.0.0.1:8080"
20 | windows:
21 | serviceUrl: "http://127.0.0.1:4723"
22 | app: "C:\\Windows\\System32\\notepad.exe"
23 | mobile:
24 | serviceUrl: "http://127.0.0.1:4723"
25 | app: "ApiDemos-debug.apk"
26 | reports:
27 | emailReport: flase
28 | htmlReport: true
29 | path: target
30 | fileName: index
31 | timestamp: false
32 | video:
33 | recording: false
34 | type: MONTE
35 | ffmpegPath:
36 | watermark: false
37 | notifier:
38 | notification: false
39 | type: slack
40 | webhookToken: WEBHOOKXXXX
41 | apiToken: APIXXXX
42 | channel: selcukes
43 | authorIcon: https://github.com/rameshbabuprudhvi.png
--------------------------------------------------------------------------------
/selcukes-snapshot/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | selcukes-parent
7 | io.github.selcukes
8 | 2.3.13-SNAPSHOT
9 |
10 |
11 | 4.0.0
12 |
13 | selcukes-snapshot
14 | selcukes-snapshot
15 | Selcukes Snapshot
16 |
17 |
18 |
19 | io.github.selcukes
20 | selcukes-bom
21 | ${project.version}
22 | pom
23 | import
24 |
25 |
26 |
27 |
28 |
29 | io.github.selcukes
30 | selcukes-commons
31 |
32 |
33 | org.testng
34 | testng
35 | provided
36 |
37 |
38 | org.projectlombok
39 | lombok
40 | provided
41 |
42 |
43 | org.seleniumhq.selenium
44 | selenium-java
45 | provided
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/selcukes-snapshot/src/main/resources/screen-size.js:
--------------------------------------------------------------------------------
1 | (() => {
2 | const fullWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.body.clientWidth, document.documentElement.clientWidth);
3 | const fullHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight);
4 | const viewWidth = window.innerWidth;
5 | const viewHeight = window.innerHeight;
6 | const exceedViewport = fullWidth > viewWidth || fullHeight > viewHeight;
7 | return {fullWidth, fullHeight, viewHeight, exceedViewport};
8 | })();
9 |
--------------------------------------------------------------------------------
/selcukes-snapshot/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.devtools.level: SEVERE
10 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
11 |
12 | # Default file output is in user's home directory.
13 | java.util.logging.FileHandler.pattern: selcukes.log
14 | java.util.logging.FileHandler.limit: 50000
15 | java.util.logging.FileHandler.count: 1
16 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
17 | java.util.logging.FileHandler.level: FINE
18 |
19 | # Limit the message that are printed on the console to INFO and above.
20 | java.util.logging.ConsoleHandler.level: FINE
21 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
22 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/selcukes-testng/src/main/resources/META-INF/services/org.testng.ITestNGListener:
--------------------------------------------------------------------------------
1 | io.github.selcukes.testng.listeners.TestListener
2 | io.github.selcukes.testng.listeners.SelcukesListener
--------------------------------------------------------------------------------
/selcukes-testng/src/test/java/io/github/selcukes/testng/tests/CucumberRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.testng.tests;
18 |
19 | import io.github.selcukes.testng.SelcukesTestNGRunner;
20 |
21 | public class CucumberRunner extends SelcukesTestNGRunner {
22 | }
23 |
--------------------------------------------------------------------------------
/selcukes-testng/src/test/java/io/github/selcukes/testng/tests/Steps.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.testng.tests;
18 |
19 | import io.cucumber.java.en.Then;
20 | import io.cucumber.java.en.When;
21 |
22 | public class Steps {
23 | @When("the Maker starts a game")
24 | public void theMakerStartsAGame() {
25 | System.out.println("the Maker starts a game");
26 |
27 | }
28 |
29 | @Then("the Maker waits for a Breaker to join")
30 | public void theMakerWaitsForABreakerToJoin() {
31 | System.out.println("the Maker waits for a Breaker to join");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/selcukes-testng/src/test/resources/features/google/sample.feature:
--------------------------------------------------------------------------------
1 | Feature: Sample Guess the word
2 |
3 | @ex
4 | Scenario: Maker starts a game
5 | When the Maker starts a game
6 | Then the Maker waits for a Breaker to join
7 |
8 | @ex1
9 | Scenario: Maker starts a game
10 | When the Maker starts a game
--------------------------------------------------------------------------------
/selcukes-testng/src/test/resources/selcukes.yaml:
--------------------------------------------------------------------------------
1 | # Selcukes Environment Properties
2 | ---
3 | projectName: Selcukes
4 | env: Dev
5 | proxy: false
6 | baseUrl:
7 | cucumber:
8 | module: google
9 | features: src/test/resources/features/${module}
10 | glue: io.github.selcukes.testng.tests
11 | tags:
12 | plugin:
13 | reports:
14 | emailReport: false
15 | htmlReport: true
16 | path: target
17 | fileName: TestReport
18 | timestamp: false
19 |
--------------------------------------------------------------------------------
/selcukes-testng/testng.yaml:
--------------------------------------------------------------------------------
1 | name: Cucumber Test Suite
2 | tests:
3 | - name: Google Module Test
4 | preserveOrder: true
5 | parameters: {
6 | selcukes.module: "google"
7 | }
8 | classes:
9 | - name: io.github.selcukes.testng.tests.CucumberRunner
10 | - name: Yahoo Module Test
11 | preserveOrder: true
12 | parameters: {
13 | selcukes.module: "yahoo"
14 | }
15 | classes:
16 | - name: io.github.selcukes.testng.tests.CucumberRunner
17 | - name: No Module Test
18 | preserveOrder: true
19 | classes:
20 | - name: io.github.selcukes.testng.tests.CucumberRunner
21 | - name: Tags Test
22 | preserveOrder: true
23 | parameters: {
24 | selcukes.tags: "@abc"
25 | }
26 | classes:
27 | - name: io.github.selcukes.testng.tests.CucumberRunner
--------------------------------------------------------------------------------
/video-recorder/src/main/java/io/github/selcukes/video/Recorder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.video;
18 |
19 | import java.io.File;
20 |
21 | public interface Recorder {
22 | /**
23 | * This method will start the recording of the execution.
24 | */
25 | void start();
26 |
27 | /**
28 | * This method will stop and save's the recording.
29 | */
30 | File stopAndSave(String filename);
31 |
32 | /**
33 | * This method will delete the recorded file,if the test is pass.
34 | */
35 | void stopAndDelete();
36 | }
37 |
--------------------------------------------------------------------------------
/video-recorder/src/main/java/io/github/selcukes/video/VideoRecorder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.video;
18 |
19 | import io.github.selcukes.commons.os.Platform;
20 | import io.github.selcukes.video.config.DefaultVideoOptions;
21 |
22 | public interface VideoRecorder extends Recorder {
23 |
24 | static DefaultVideoOptions videoConfig() {
25 | DefaultVideoOptions.DefaultVideoOptionsBuilder optionsBuilder = DefaultVideoOptions.builder();
26 | if (Platform.isLinux()) {
27 | optionsBuilder.ffmpegFormat("x11grab");
28 | optionsBuilder.ffmpegDisplay(":0.0");
29 | }
30 | return optionsBuilder.build();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/video-recorder/src/main/java/io/github/selcukes/video/config/DefaultVideoOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.video.config;
18 |
19 | import io.github.selcukes.commons.config.Config;
20 | import lombok.Builder;
21 | import lombok.Data;
22 | import lombok.EqualsAndHashCode;
23 |
24 | import java.awt.Dimension;
25 | import java.awt.Toolkit;
26 |
27 | @EqualsAndHashCode(callSuper = true)
28 | @Data
29 | @Builder
30 | public class DefaultVideoOptions extends Config {
31 | @Builder.Default
32 | String videoFolder = "video-report";
33 | @Builder.Default
34 | int frameRate = 24;
35 | @Builder.Default
36 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
37 | @Builder.Default
38 | String ffmpegFormat = "gdigrab";
39 | @Builder.Default
40 | String ffmpegDisplay = "desktop";
41 | @Builder.Default
42 | String pixelFormat = "yuv420p";
43 | }
44 |
--------------------------------------------------------------------------------
/video-recorder/src/main/java/io/github/selcukes/video/enums/RecorderType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.video.enums;
18 |
19 | public enum RecorderType {
20 | MONTE,
21 | FFMPEG
22 | }
23 |
--------------------------------------------------------------------------------
/video-recorder/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------
/video-recorder/src/test/java/io/github/selcukes/video/tests/VideoTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.video.tests;
18 |
19 | import io.github.selcukes.commons.Await;
20 | import io.github.selcukes.commons.os.Platform;
21 | import io.github.selcukes.video.Recorder;
22 | import io.github.selcukes.video.RecorderFactory;
23 | import io.github.selcukes.video.enums.RecorderType;
24 | import org.testng.Assert;
25 | import org.testng.annotations.Test;
26 |
27 | import java.io.File;
28 |
29 | public class VideoTest {
30 | @Test
31 | public void recordVideo() {
32 | if (Platform.isWindows()) {
33 | Recorder recorder = RecorderFactory.getRecorder(RecorderType.MONTE);
34 | recorder.start();
35 | Await.until(5);
36 | File file = recorder.stopAndSave("test");
37 | Assert.assertTrue(file.getAbsolutePath().contains("mp4"));
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/webdriver-binaries/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | selcukes-parent
7 | io.github.selcukes
8 | 2.3.13-SNAPSHOT
9 |
10 |
11 | 4.0.0
12 | webdriver-binaries
13 |
14 | webdriver-binaries
15 | Automatically downloads and configures Selenium WebDriver binary files
16 |
17 | **/VersionComparator.java
18 |
19 |
20 |
21 |
22 | io.github.selcukes
23 | selcukes-bom
24 | ${project.version}
25 | pom
26 | import
27 |
28 |
29 |
30 |
31 |
32 | io.github.selcukes
33 | selcukes-commons
34 |
35 |
36 | org.seleniumhq.selenium
37 | selenium-java
38 | provided
39 |
40 |
41 | org.testng
42 | testng
43 | test
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/webdriver-binaries/src/main/java/io/github/selcukes/wdb/BinaryInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.wdb;
18 |
19 | public record BinaryInfo(String binaryProperty, String binaryPath) {
20 | }
21 |
--------------------------------------------------------------------------------
/webdriver-binaries/src/main/java/io/github/selcukes/wdb/enums/DownloaderType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.wdb.enums;
18 |
19 | public enum DownloaderType {
20 | ZIP("zip"),
21 | TAR("tar.gz"),
22 | JAR("jar");
23 | final String name;
24 |
25 | DownloaderType(String name) {
26 | this.name = name;
27 | }
28 |
29 | public String getName() {
30 | return name;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/webdriver-binaries/src/main/java/io/github/selcukes/wdb/enums/DriverType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Ramesh Babu Prudhvi.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package io.github.selcukes.wdb.enums;
18 |
19 | public enum DriverType {
20 | CHROME("chrome"),
21 | FIREFOX("gecko"),
22 | IEXPLORER("ie"),
23 | EDGE("edge"),
24 | OPERA("opera");
25 |
26 | final String name;
27 |
28 | DriverType(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/webdriver-binaries/src/main/resources/selcukes-logback.yaml:
--------------------------------------------------------------------------------
1 | # To add the FileHandler, use the following line.
2 | handlers: java.util.logging.FileHandler, java.util.logging.ConsoleHandler
3 |
4 | #.level: INFO
5 | .level: INFO
6 |
7 | # For example, set the io.github.selcukes.core logger to only log SEVERE
8 | io.github.selcukes.level: ALL
9 | io.github.selcukes.handler: java.util.logging.ConsoleHandler
10 |
11 | # Default file output is in user's home directory.
12 | java.util.logging.FileHandler.pattern: target/selcukes.log
13 | java.util.logging.FileHandler.limit: 50000
14 | java.util.logging.FileHandler.count: 1
15 | java.util.logging.FileHandler.formatter: io.github.selcukes.commons.logging.SelcukesLoggerFormatter
16 | java.util.logging.FileHandler.level: FINE
17 |
18 | # Limit the message that are printed on the console to INFO and above.
19 | java.util.logging.ConsoleHandler.level: FINE
20 | #java.util.logging.ConsoleHandler.formatter : java.util.logging.SimpleFormatter
21 | java.util.logging.ConsoleHandler.formatter: io.github.selcukes.commons.logging.SelcukesColorFormatter
--------------------------------------------------------------------------------