add tests
This commit is contained in:
parent
92b0a14a00
commit
f9143fb60b
@ -1,13 +1,83 @@
|
|||||||
package com.example.demo;
|
package com.example.demo;
|
||||||
|
|
||||||
|
import com.example.demo.speaker.service.MethodService;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class DemoApplicationTests {
|
class DemoApplicationTests {
|
||||||
|
@Autowired
|
||||||
|
private MethodService methodService;
|
||||||
|
@Test
|
||||||
|
void testIntSum() {
|
||||||
|
Integer res = Integer.valueOf(methodService.Sum(2, 2, "int"));
|
||||||
|
Assertions.assertEquals(4, res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testStringSum() {
|
||||||
|
String res = methodService.Sum("hello, ", 2, "string");
|
||||||
|
Assertions.assertEquals("hello, 2", res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testBooleanSum() {
|
||||||
|
String res = methodService.Sum(true, true, "boolean");
|
||||||
|
Assertions.assertEquals("true", res);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void testIntDiff() {
|
||||||
|
Integer res = Integer.valueOf(methodService.Ras(4, 2, "int"));
|
||||||
|
Assertions.assertEquals(2, res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testStringDiff() {
|
||||||
|
String res = methodService.Ras("hello2", 2, "string");
|
||||||
|
Assertions.assertEquals("hell", res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testBooleanDiff() {
|
||||||
|
String res = methodService.Ras(1, 2, "boolean");
|
||||||
|
Assertions.assertEquals(true, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testIntMultiple() {
|
||||||
|
Integer res = Integer.valueOf(methodService.Pros(2, 3, "int"));
|
||||||
|
Assertions.assertEquals(6, res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testStringMultiple() {
|
||||||
|
String res = methodService.Pros("test", 2, "string");
|
||||||
|
Assertions.assertEquals("testtest", res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testBooleanMultiple() {
|
||||||
|
String res = methodService.Pros(true, 2, "boolean");
|
||||||
|
Assertions.assertEquals("true", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testIntDivide() {
|
||||||
|
Integer res = Integer.valueOf(methodService.Del(10, 2, "int"));
|
||||||
|
Assertions.assertEquals(5, res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testStringDivide() {
|
||||||
|
String res = methodService.Del("test", 2, "string");
|
||||||
|
Assertions.assertEquals("false", res);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testBooleanDivide() {
|
||||||
|
String res = methodService.Del(true, 2, "boolean");
|
||||||
|
Assertions.assertEquals("false", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testErrorErrorWired() {
|
||||||
|
Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> methodService.Sum(1, 2, "date"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user