<commit_before>package org.junit.tests.running.methods;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import java.util.HashSet;

import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.hamcrest.CoreMatchers;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

public class AnnotationTest extends TestCase {
	static boolean run;

	@Override
	public void setUp() {
		run= false;
	}
	
	static public class SimpleTest {
		@Test public void success() {
			run= true;
		}
	}

	public void testAnnotatedMethod() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SimpleTest.class);
		assertTrue(run);
	}
	
	@RunWith(JUnit4.class)
	static public class SimpleTestWithFutureProofExplicitRunner {
		@Test public void success() {
			run= true;
		}
	}

	public void testAnnotatedMethodWithFutureProofExplicitRunner() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SimpleTestWithFutureProofExplicitRunner.class);
		assertTrue(run);
	}
	
	static public class SetupTest {
		@Before public void before() {
			run= true;
		}
		@Test public void success() {
		}
	}
	
	public void testSetup() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SetupTest.class);
		assertTrue(run);
	}
	
	static public class TeardownTest {
		@After public void after() {
			run= true;
		}
		@Test public void success() {
		}
	}

	public void testTeardown() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(TeardownTest.class);
		assertTrue(run);		
	}
	
	static public class FailureTest {
		@Test public void error() throws Exception {
			org.junit.Assert.fail();
		}
	}
	
	public void testRunFailure() throws Exception {
		JUnitCore runner= new JUnitCore();
		Result result= runner.run(FailureTest.class);
		assertEquals(1, result.getRunCount());
		assertEquals(1, result.getFailureCount());
		assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());
	}
	
	static public class SetupFailureTest {
		@Before public void before() {
			throw new Error();
		}
		@Test public void test() {
			run= true;
		}
	}
	
	public void testSetupFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(SetupFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(1, runner.getFailureCount());
		assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
		assertFalse(run);
	}

	static public class TeardownFailureTest {
		@After public void after() {
			throw new Error();
		}
		@Test public void test() {
		}
	}
	
	public void testTeardownFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(TeardownFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(1, runner.getFailureCount());
		assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
	}
	
	static public class TestAndTeardownFailureTest {
		@After public void after() {
			throw new Error("hereAfter");
		}
		@Test public void test() throws Exception {
			throw new Exception("inTest");
		}
	}
	
	public void testTestAndTeardownFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(TestAndTeardownFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(2, runner.getFailureCount());
		assertThat(
				runner.getFailures().toString(),
				CoreMatchers.<String> both(containsString("hereAfter")).and(
						containsString("inTest")));
	}
	
	static public class TeardownAfterFailureTest {
		@After public void after() {
			run= true;
		}
		@Test public void test() throws Exception {
			throw new Exception();
		}
	}
	
	public void testTeardownAfterFailure() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(TeardownAfterFailureTest.class);
		assertTrue(run);
	}
	
	static int count;
	static Collection<Object> tests;
	static public class TwoTests {
		@Test public void one() {
			count++;
			tests.add(this);
		}
		@Test public void two() {
			count++;
			tests.add(this);
		}<commit_msg>Use allOf() instead of both() to avoid type parameter<commit_after>package org.junit.tests.running.methods;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

import java.util.Collection;
import java.util.HashSet;

import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

public class AnnotationTest extends TestCase {
	static boolean run;

	@Override
	public void setUp() {
		run= false;
	}
	
	static public class SimpleTest {
		@Test public void success() {
			run= true;
		}
	}

	public void testAnnotatedMethod() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SimpleTest.class);
		assertTrue(run);
	}
	
	@RunWith(JUnit4.class)
	static public class SimpleTestWithFutureProofExplicitRunner {
		@Test public void success() {
			run= true;
		}
	}

	public void testAnnotatedMethodWithFutureProofExplicitRunner() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SimpleTestWithFutureProofExplicitRunner.class);
		assertTrue(run);
	}
	
	static public class SetupTest {
		@Before public void before() {
			run= true;
		}
		@Test public void success() {
		}
	}
	
	public void testSetup() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(SetupTest.class);
		assertTrue(run);
	}
	
	static public class TeardownTest {
		@After public void after() {
			run= true;
		}
		@Test public void success() {
		}
	}

	public void testTeardown() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(TeardownTest.class);
		assertTrue(run);		
	}
	
	static public class FailureTest {
		@Test public void error() throws Exception {
			org.junit.Assert.fail();
		}
	}
	
	public void testRunFailure() throws Exception {
		JUnitCore runner= new JUnitCore();
		Result result= runner.run(FailureTest.class);
		assertEquals(1, result.getRunCount());
		assertEquals(1, result.getFailureCount());
		assertEquals(AssertionError.class, result.getFailures().get(0).getException().getClass());
	}
	
	static public class SetupFailureTest {
		@Before public void before() {
			throw new Error();
		}
		@Test public void test() {
			run= true;
		}
	}
	
	public void testSetupFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(SetupFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(1, runner.getFailureCount());
		assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
		assertFalse(run);
	}

	static public class TeardownFailureTest {
		@After public void after() {
			throw new Error();
		}
		@Test public void test() {
		}
	}
	
	public void testTeardownFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(TeardownFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(1, runner.getFailureCount());
		assertEquals(Error.class, runner.getFailures().get(0).getException().getClass());
	}
	
	static public class TestAndTeardownFailureTest {
		@After public void after() {
			throw new Error("hereAfter");
		}
		@Test public void test() throws Exception {
			throw new Exception("inTest");
		}
	}
	
	public void testTestAndTeardownFailure() throws Exception {
		JUnitCore core= new JUnitCore();
		Result runner= core.run(TestAndTeardownFailureTest.class);
		assertEquals(1, runner.getRunCount());
		assertEquals(2, runner.getFailureCount());
		assertThat(runner.getFailures().toString(), allOf(containsString("hereAfter"), containsString("inTest")));
	}
	
	static public class TeardownAfterFailureTest {
		@After public void after() {
			run= true;
		}
		@Test public void test() throws Exception {
			throw new Exception();
		}
	}
	
	public void testTeardownAfterFailure() throws Exception {
		JUnitCore runner= new JUnitCore();
		runner.run(TeardownAfterFailureTest.class);
		assertTrue(run);
	}
	
	static int count;
	static Collection<Object> tests;
	static public class TwoTests {
		@Test public void one() {
			count++;
			tests.add(this);
		}
		@Test public void two() {
			count++;
			tests.add(this);
		}
{'fraction_non_alphanumeric': 0.11583011583011583, 'fraction_numerical': 0.0029525323642970703, 'mean_word_length': 4.570524984187223, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1088246', 'n_tokens_mistral': 2967, 'n_tokens_neox': 2692, 'n_words': 679}