<commit_before>/*
 * Copyright 2015 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.gen5.engine.junit5;

import static org.junit.gen5.api.Assertions.*;
import static org.junit.gen5.api.Assumptions.*;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Assert;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.TestDescriptor;
import org.junit.gen5.engine.TestExecutionListener;
import org.junit.gen5.engine.TestPlanSpecification;

/**
 * Unit tests for {@link JUnit5TestEngine}.
 *
 * @author <NAME>
 * @since 5.0
 */
public class JUnit5TestEngineTests {

	@org.junit.Test
	public void executeTestsFromDescriptorsGeneratedFromClasses() {
		JUnit5TestEngine engine = new JUnit5TestEngine();

		TestPlanSpecification spec = TestPlanSpecification.builder().classes(LocalTestCase.class).build();

		List<TestDescriptor> descriptors = engine.discoverTests(spec);
		Assert.assertNotNull(descriptors);
		Assert.assertEquals("# tests", 3, descriptors.size());

		TrackingTestExecutionListener listener = new TrackingTestExecutionListener();

		engine.execute(descriptors, listener);

		Assert.assertEquals(3, listener.testStartedCount.get());
		Assert.assertEquals(1, listener.testSucceededCount.get());
		Assert.assertEquals(1, listener.testAbortedCount.get());
		Assert.assertEquals(1, listener.testFailedCount.get());
	}


	private static class LocalTestCase {

		@Test<commit_msg>Introduce test for test execution based on test ID<commit_after>/*
 * Copyright 2015 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.gen5.engine.junit5;

import static org.junit.gen5.api.Assertions.*;
import static org.junit.gen5.api.Assumptions.*;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Assert;
import org.junit.gen5.api.Test;
import org.junit.gen5.engine.TestDescriptor;
import org.junit.gen5.engine.TestExecutionListener;
import org.junit.gen5.engine.TestPlanSpecification;

/**
 * Unit tests for {@link JUnit5TestEngine}.
 *
 * @author <NAME>
 * @since 5.0
 */
public class JUnit5TestEngineTests {

	@org.junit.Test
	public void executeTestsFromFromClasses() {
		JUnit5TestEngine engine = new JUnit5TestEngine();

		// @formatter:off
		TestPlanSpecification spec = TestPlanSpecification.builder()
			.classes(LocalTestCase.class)
			.build();
		// @formatter:on

		List<TestDescriptor> descriptors = engine.discoverTests(spec);
		Assert.assertNotNull(descriptors);
		Assert.assertEquals("# tests", 3, descriptors.size());

		TrackingTestExecutionListener listener = new TrackingTestExecutionListener();

		engine.execute(descriptors, listener);

		Assert.assertEquals(3, listener.testStartedCount.get());
		Assert.assertEquals(1, listener.testSucceededCount.get());
		Assert.assertEquals(1, listener.testAbortedCount.get());
		Assert.assertEquals(1, listener.testFailedCount.get());
	}

	@org.junit.Test
	public void executeTestFromTestId() {
		JUnit5TestEngine engine = new JUnit5TestEngine();

		// @formatter:off
		TestPlanSpecification spec = TestPlanSpecification.builder()
			.uniqueIds("junit5:org.junit.gen5.engine.junit5.JUnit5TestEngineTests$LocalTestCase#alwaysPasses()")
			.build();
		// @formatter:on

		List<TestDescriptor> descriptors = engine.discoverTests(spec);
		Assert.assertNotNull(descriptors);
		Assert.assertEquals("# tests", 1, descriptors.size());

		TrackingTestExecutionListener listener = new TrackingTestExecutionListener();

		engine.execute(descriptors, listener);

		Assert.assertEquals(1, listener.testStartedCount.get());
		Assert.assertEquals(1, listener.testSucceededCount.get());
	}


	private static class LocalTestCase {

		@Test
{'fraction_non_alphanumeric': 0.11414868105515588, 'fraction_numerical': 0.015107913669064749, 'mean_word_length': 5.319696969696969, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4048516', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1199, 'n_words': 264}