Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2019 Qameta Software OÜ
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.xctest;
import io.qameta.allure.Reader;
import io.qameta.allure.core.Configuration;
import io.qameta.allure.core.ResultsVisitor;
import io.qameta.allure.entity.Status;
import io.qameta.allure.entity.Step;
import io.qameta.allure.entity.TestResult;
import io.qameta.allure.entity.Timeable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xmlwise.Plist;
import xmlwise.XmlParseException;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DateTimeException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import static io.qameta.allure.entity.LabelName.RESULT_FORMAT;
import static io.qameta.allure.entity.LabelName.SUITE;
import static java.util.Collections.emptyList;
/**
* @author charlie (Dmitry Baev).
*/
public class XcTestPlugin implements Reader {
private static final Logger LOGGER = LoggerFactory.getLogger(XcTestPlugin.class);
public static final String XCTEST_RESULTS_FORMAT = "xctest";
private static final String TESTABLE_SUMMARIES = "TestableSummaries";
private static final String TESTS = "Tests";
private static final String SUB_TESTS = "Subtests";
private static final String TITLE = "Title";
private static final String SUB_ACTIVITIES = "SubActivities";
private static final String ACTIVITY_SUMMARIES = "ActivitySummaries";
private static final String HAS_SCREENSHOT = "HasScreenshotData";
private static final String ATTACHMENTS = "Attachments";
private static final String ATTACHMENT_FILENAME = "Filename";
@Override
public void readResults(final Configuration configuration,
final ResultsVisitor visitor,
final Path directory) {
final List testSummaries = listSummaries(directory);
testSummaries.forEach(summaryPath -> readSummaries(directory, summaryPath, visitor));
}
private void readSummaries(final Path directory, final Path testSummariesPath, final ResultsVisitor visitor) {
try {
LOGGER.info("Parse file {}", testSummariesPath);
final Map loaded = Plist.load(testSummariesPath.toFile());
final List> summaries = asList(loaded.getOrDefault(TESTABLE_SUMMARIES, emptyList()));
summaries.forEach(summary -> parseSummary(directory, summary, visitor));
} catch (XmlParseException | IOException e) {
LOGGER.error("Could not parse file {}: {}", testSummariesPath, e);
}
}
private void parseSummary(final Path directory, final Object summary, final ResultsVisitor visitor) {
final Map props = asMap(summary);
final String name = ResultsUtils.getTestName(props);
final List