001/*
002 * JDrupes Builder
003 * Copyright (C) 2025 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.builder.api;
020
021import java.util.Optional;
022import static org.jdrupes.builder.api.ResourceType.TestResultType;
023
024/// Provides the results from running tests.
025///
026public interface TestResult extends Resource, FaultAware {
027
028    /// The test project.
029    ///
030    /// @return the project
031    ///
032    Project project();
033
034    /// The name of the test or test suite.
035    ///
036    /// @return the name
037    ///
038    @Override
039    Optional<String> name();
040
041    /// Returns the number of executed tests.
042    ///
043    /// @return the number
044    ///
045    long executed();
046
047    /// Returns the number of test failures.
048    ///
049    /// @return the number
050    ///
051    long failed();
052
053    /// Creates a new test result from the given values.
054    ///
055    /// @param project the project
056    /// @param provider the provider
057    /// @param name the name
058    /// @param executed the executed
059    /// @param failed the failed
060    /// @return the test result
061    ///
062    @SuppressWarnings("PMD.ShortMethodName")
063    static TestResult of(Project project, ResourceProvider provider,
064            String name, long executed, long failed) {
065        return ResourceFactory.create(
066            TestResultType, project, provider, name, executed, failed);
067    }
068}