-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add junit 3 test (disabled) #134
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
...ox_junit_cleanup_test/src/org/eclipse/jdt/ui/tests/quickfix/Java8/JUnit3CleanupCases.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
package org.eclipse.jdt.ui.tests.quickfix.Java8; | ||
Check warning Code scanning / Pmd (reported by Codacy) Package name contains upper case characters Warning test
Package name contains upper case characters
|
||
|
||
/*- | ||
* #%L | ||
* Sandbox junit cleanup test | ||
* %% | ||
* Copyright (C) 2024 hammer | ||
* %% | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is | ||
* available at https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
* #L% | ||
*/ | ||
|
||
enum JUnit3CleanupCases{ | ||
Junit3Case( | ||
""" | ||
package test; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
public class MyTest extends TestCase { | ||
|
||
public MyTest(String name) { | ||
super(name); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
// Setup vor jedem Test | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
// Aufräumen nach jedem Test | ||
} | ||
|
||
public static Test suite() { | ||
TestSuite suite = new TestSuite(); | ||
suite.addTest(new MyTest("testBasicAssertions")); | ||
suite.addTest(new MyTest("testArrayAssertions")); | ||
suite.addTest(new MyTest("testWithAssume")); | ||
suite.addTest(new MyTest("testAssertThat")); | ||
suite.addTest(new MyTest("testEqualityWithDelta")); | ||
suite.addTest(new MyTest("testFail")); | ||
return suite; | ||
} | ||
|
||
public void testBasicAssertions() { | ||
assertEquals("Values should match", 42, 42); | ||
assertTrue("Condition should be true", true); | ||
assertFalse("Condition should be false", false); | ||
assertNull("Should be null", null); | ||
assertNotNull("Should not be null", new Object()); | ||
} | ||
|
||
public void testArrayAssertions() { | ||
int[] expected = {1, 2, 3}; | ||
int[] actual = {1, 2, 3}; | ||
assertEquals("Arrays should match", expected.length, actual.length); | ||
for (int i = 0; i < expected.length; i++) { | ||
assertEquals("Array element mismatch at index " + i, expected[i], actual[i]); | ||
} | ||
} | ||
|
||
public void testWithAssume() { | ||
assumeTrue("Precondition failed", true); | ||
assumeFalse("Precondition not met", false); | ||
} | ||
|
||
public void testAssertThat() { | ||
assertEquals("Value should match", 42, 42); // Ersatz für assertThat in JUnit 3 | ||
} | ||
|
||
public void testEqualityWithDelta() { | ||
assertEquals("Floating point equality with delta", 0.1 + 0.2, 0.3, 0.0001); | ||
} | ||
|
||
public void testFail() { | ||
fail("This test should fail with a message."); | ||
} | ||
} | ||
|
||
""" | ||
, | ||
""" | ||
package test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.jupiter.api.Assumptions.*; | ||
|
||
import org.junit.jupiter.api.*; | ||
|
||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class MyTest { | ||
|
||
@BeforeEach | ||
public void setUp() throws Exception { | ||
// Setup vor jedem Test | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() throws Exception { | ||
// Aufräumen nach jedem Test | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
public void testBasicAssertions() { | ||
assertEquals(42, 42, "Values should match"); | ||
assertTrue(true, "Condition should be true"); | ||
assertFalse(false, "Condition should be false"); | ||
assertNull(null, "Should be null"); | ||
assertNotNull(new Object(), "Should not be null"); | ||
} | ||
|
||
@Test | ||
@Order(2) | ||
public void testArrayAssertions() { | ||
int[] expected = {1, 2, 3}; | ||
int[] actual = {1, 2, 3}; | ||
assertArrayEquals(expected, actual, "Arrays should match"); | ||
} | ||
|
||
@Test | ||
@Order(3) | ||
public void testWithAssume() { | ||
assumeTrue(true, "Precondition failed"); | ||
assumeFalse(false, "Precondition not met"); | ||
} | ||
|
||
@Test | ||
@Order(4) | ||
public void testAssertThat() { | ||
assertThat("Value should match", 42, is(42)); | ||
} | ||
|
||
@Test | ||
@Order(5) | ||
public void testEqualityWithDelta() { | ||
assertEquals(0.3, 0.1 + 0.2, 0.0001, "Floating point equality with delta"); | ||
} | ||
|
||
@Test | ||
@Order(6) | ||
public void testFail() { | ||
fail("This test should fail with a message."); | ||
} | ||
} | ||
|
||
""" | ||
); //$NON-NLS-1$ | ||
|
||
String given; | ||
String expected; | ||
|
||
JUnit3CleanupCases(String given, String expected) { | ||
this.given=given; | ||
this.expected=expected; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / PMD
Package name contains upper case characters Warning test