Обновил junit и добавил тест на добавление элементов

This commit is contained in:
2025-02-03 17:37:34 +03:00
parent a87c13dc42
commit 65f7586e24
2 changed files with 27 additions and 35 deletions

View File

@@ -9,10 +9,15 @@
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.1</version>
</dependency>
</dependencies>
<build>

View File

@@ -1,38 +1,25 @@
package ru.spbstu.telematics.java;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
import java.util.TreeSet;
class MyTreeSetTests {
MyTreeSet<Integer> myTreeSet;
TreeSet<Integer> treeSet;
@BeforeEach
void setUp() {
myTreeSet = new MyTreeSet<>();
treeSet = new TreeSet<>();
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
@Test
void testAdd() {
assertEquals(myTreeSet.add(150), treeSet.add(150));
assertEquals(myTreeSet.add(200), treeSet.add(200));
assertEquals(myTreeSet.add(150), treeSet.add(150));
}
}