• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Test类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.junit.gen5.api.Test的典型用法代码示例。如果您正苦于以下问题:Java Test类的具体用法?Java Test怎么用?Java Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Test类属于org.junit.gen5.api包,在下文中一共展示了Test类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: persistResolvedProject

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load resolved projects")
void persistResolvedProject() {
	ResolvedProject project = new ResolvedProject(
			ProjectCoordinates.from("project", "artifact"),
			of(
					ArtifactCoordinates.from("project", "artifact", "v1"),
					ArtifactCoordinates.from("project", "artifact", "v2"))
	);

	String artifactAsYaml = persister.writeResolvedProject(project);
	ResolvedProject loadedProject = persister.readResolvedProject(artifactAsYaml);

	assertThat(loadedProject).isEqualTo(project);
	// equality is based on coordinates so we have to check versions explicitly
	assertThat(loadedProject.versions()).isEqualTo(project.versions());
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:18,代码来源:YamlPersisterTest.java


示例2: persistResolvedArtifact

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load resolved artifacts")
void persistResolvedArtifact() {
	ResolvedArtifact artifact = new ResolvedArtifact(
			ArtifactCoordinates.from("artifact.group", "artifact", "version"),
			of(
					ArtifactCoordinates.from("dependee1.group", "dep", "v1"),
					ArtifactCoordinates.from("dependee2.group", "dependee", "v2"))
	);

	String artifactAsYaml = persister.writeResolvedArtifact(artifact);
	ResolvedArtifact loadedArtifact = persister.readResolvedArtifact(artifactAsYaml);

	assertThat(loadedArtifact).isEqualTo(artifact);
	// equality is based on coordinates so we have to check dependees explicitly
	assertThat(loadedArtifact.dependees()).isEqualTo(artifact.dependees());
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:18,代码来源:YamlPersisterTest.java


示例3: persistAnalyzedArtifact

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("can dump and load analyzed artifacts")
void persistAnalyzedArtifact() {
	AnalyzedArtifact artifact = new AnalyzedArtifact(
			ArtifactCoordinates.from("artifact.group", "artifact", "version"),
			of(
					Violation.buildFor(
							Type.of("artifact.package", "Class"),
							of(
									InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
									InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))),
					Violation.buildFor(
							Type.of("artifact.package", "Class"),
							of(
									InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
									InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))))
	);

	String artifactAsYaml = persister.writeAnalyzedArtifact(artifact);
	AnalyzedArtifact loadedArtifact = persister.readAnalyzedArtifact(artifactAsYaml);

	assertThat(loadedArtifact).isEqualTo(artifact);
	// equality is based on coordinates so we have to check violations explicitly
	assertThat(loadedArtifact.violations()).isEqualTo(artifact.violations());
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:26,代码来源:YamlPersisterTest.java


示例4: testClone

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link QueueElement#clone()} method will clone correctly. */
@Test
public void testClone() {
    final QueueElement elem = new QueueElement();
    final QueueElement clone;
    final SongInfo song = new SongInfo(5);
    final SongInfo cloneSong;
    
    elem.setID(7);
    elem.setQueueIndex(11);
    elem.setPlayIndex(13);
    elem.setSong(song);
    
    clone = elem.clone();
    assertNotNull(clone);
    assertTrue(elem != clone);
    assertEquals(elem.getID(), clone.getID());
    assertEquals(elem.getQueueIndex(), clone.getQueueIndex());
    assertEquals(elem.getPlayIndex(), clone.getPlayIndex());
    
    cloneSong = clone.getSong();
    assertNotNull(cloneSong);
    assertTrue(song != cloneSong);
    assertEquals(song.getID(), cloneSong.getID());
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:26,代码来源:QueueElementTest.java


示例5: testSize

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link IDSet#size()} returns the set's size correctly. */
@Test
public void testSize() {
    final IDSet<TestIdentifiable> s = new IDSet<>();
    
    assertEquals(0, s.size());
    
    s.add(new TestIdentifiable(3));
    assertEquals(1, s.size());
    
    s.add(new TestIdentifiable(7));
    assertEquals(2, s.size());
    
    s.add(new TestIdentifiable(11));
    assertEquals(3, s.size());
    
    s.clear();
    assertEquals(0, s.size());
    assertEquals("[]", s.toString());
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:21,代码来源:IDSetTest.java


示例6: testSetPlayIndex_ValidQueue_MiddleElement

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that a queue's play index can be set one of its middle elements */
@Test
public void testSetPlayIndex_ValidQueue_MiddleElement() throws IOException {
    final Library lib = LibraryRESTCalls.getLibrary();
    final int songID1 = lib.getSongs().get(0).getID();
    final int songID2 = lib.getSongs().get(1).getID();
    final int songID3 = lib.getSongs().get(2).getID();
    Queue q = QueueRESTCalls.createQueue();
    final int qID;
    
    queuesToCleanup.add(q);
    qID = q.getID();
    
    // Add songs to the queue
    q = QueueRESTCalls.addLast(200, qID, songID1, songID2, songID3);
    
    // Verify that the play index can be set to 1
    q = QueueRESTCalls.setPlayIndex(qID, 1);
    assertThat(q.getPlayIndex(), is(equalTo(1)));
    assertThat(q.getElement(0).getPlayIndex(), is(equalTo(-1)));
    assertThat(q.getElement(1).getPlayIndex(), is(equalTo(0)));
    assertThat(q.getElement(2).getPlayIndex(), is(equalTo(1)));
    
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:25,代码来源:QueueRESTTest.java


示例7: testRemoveElement_Only

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the a song can be removed from a queue when it is the only element in the queue. */
@Test
public void testRemoveElement_Only() throws IOException {
    final Library lib = LibraryRESTCalls.getLibrary();
    Queue q = QueueRESTCalls.createQueue();
    final int qID;
    
    queuesToCleanup.add(q);
    qID = q.getID();
    
    // Add a song to the queue
    q = QueueRESTCalls.addLast(200, qID, lib.getSongs().get(0).getID());
    
    // Remove the song and verify the returned queue does not contain the song
    q = QueueRESTCalls.removeElement(qID, 0);
    assertEquals(0, q.size());
    
    // Get the queue and verify the song has been removed
    q = QueueRESTCalls.getQueue(qID);
    assertEquals(0, q.size());
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:22,代码来源:QueueRESTTest.java


示例8: testSortDescNullsFirst

import org.junit.gen5.api.Test; //导入依赖的package包/类
/**
 * Tests to ensure that a {@link NullComparator} can be used to sort a collection that contains {@code null}
 * elements in descending order. The {@code null}s should be at the beginning of the sorted collection.
 */
@Test
public void testSortDescNullsFirst() {
    final Integer a = 13;
    final Integer b = null;
    final Integer c = 7;
    final Integer d = null;
    final Integer e = 11;
    final List<Integer> list = new ArrayList<>();
    
    list.add(a);
    list.add(b);
    list.add(c);
    list.add(d);
    list.add(e);
    
    Collections.sort(list, new IntegerNullComparator(NullComparator.Order.DESC_NULLS_FIRST));
    
    assertNull(list.get(0));
    assertNull(list.get(1));
    assertEquals(a, list.get(2));
    assertEquals(e, list.get(3));
    assertEquals(c, list.get(4));
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:28,代码来源:NullComparatorTest.java


示例9: testSetPlayIndex_ValidQueue_FirstElement

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that a queue's play index can be set to its first element */
@Test
public void testSetPlayIndex_ValidQueue_FirstElement() throws IOException {
    final Library lib = LibraryRESTCalls.getLibrary();
    final int songID1 = lib.getSongs().get(0).getID();
    final int songID2 = lib.getSongs().get(1).getID();
    final int songID3 = lib.getSongs().get(2).getID();
    Queue q = QueueRESTCalls.createQueue();
    final int qID;
    
    queuesToCleanup.add(q);
    qID = q.getID();
    
    // Add songs to the queue
    q = QueueRESTCalls.addLast(200, qID, songID1, songID2, songID3);
    
    // Verify that the play index can be set to 2
    q = QueueRESTCalls.setPlayIndex(qID, 0);
    assertThat(q.getPlayIndex(), is(equalTo(0)));
    assertThat(q.getElement(0).getPlayIndex(), is(equalTo(0)));
    assertThat(q.getElement(1).getPlayIndex(), is(equalTo(1)));
    assertThat(q.getElement(2).getPlayIndex(), is(equalTo(2)));
    
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:25,代码来源:QueueRESTTest.java


示例10: testIndicesAfterAddSongLast

import org.junit.gen5.api.Test; //导入依赖的package包/类
/**
 * Tests to ensure that the queue elements' indices are correct after the {@link Queue#addSongLast(SongInfo)}
 * function is used to add a song to the queue.
 */
@Test
public void testIndicesAfterAddSongLast() {
    final Queue queue = new Queue();
    final SongInfo a = new SongInfo(5);
    final SongInfo b = new SongInfo(7);
    final SongInfo c = new SongInfo(11);
    
    queue.addSongLast(a);
    assertEquals(0, queue.getElement(0).getPlayIndex());
    assertEquals(0, queue.getElement(0).getQueueIndex());
    
    queue.addSongLast(b);
    assertEquals(0, queue.getElement(0).getPlayIndex());
    assertEquals(0, queue.getElement(0).getQueueIndex());
    assertEquals(1, queue.getElement(1).getPlayIndex());
    assertEquals(1, queue.getElement(1).getQueueIndex());
    
    queue.addSongLast(c);
    assertEquals(0, queue.getElement(0).getPlayIndex());
    assertEquals(0, queue.getElement(0).getQueueIndex());
    assertEquals(1, queue.getElement(1).getPlayIndex());
    assertEquals(1, queue.getElement(1).getQueueIndex());
    assertEquals(2, queue.getElement(2).getPlayIndex());
    assertEquals(2, queue.getElement(2).getQueueIndex());
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:30,代码来源:QueueTest.java


示例11: testClear

import org.junit.gen5.api.Test; //导入依赖的package包/类
/** Tests to ensure that the {@link IDSet#clear()} function empties the set. */
@Test
@SuppressWarnings("unused")
public void testClear() {
    final IDSet<TestIdentifiable> s = new IDSet<>();
    int count = 0;
    
    s.add(new TestIdentifiable(3));
    s.add(new TestIdentifiable(7));
    s.add(new TestIdentifiable(11));
    
    assertNotEquals(0, s.size());
    assertNotEquals("[]", s.toString());
    s.clear();
    assertEquals(0, s.size());
    
    for(TestIdentifiable i : s) {
        count++;
    }
    
    assertEquals(0, count);
    assertEquals("[]", s.toString());
}
 
开发者ID:eviljoe,项目名称:evilmusic,代码行数:24,代码来源:IDSetTest.java


示例12: testCreateServiceInfo

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a valid kubernetes service we provide a valid config service info")
public void testCreateServiceInfo() throws Exception {
    Service service = new Service();

    service.setMetadata(getObjectMeta());
    service.setSpec(getServiceSpec());

    ConfigServerServiceInfo serviceInfo = configServerServiceInfoCreator.createServiceInfo(service);
    assertNotNull(serviceInfo);
    assertEquals("http://config-service:8080/", serviceInfo.getUri());
}
 
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:13,代码来源:ConfigServerServiceInfoCreatorTest.java


示例13: testCreateServiceInfo_ServiceNoPorts

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a kubernetes service without ports we launch a NPE")
public void testCreateServiceInfo_ServiceNoPorts() throws Exception {
    Service service = new Service();
    service.setMetadata(getObjectMeta());

    expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
 
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:9,代码来源:ConfigServerServiceInfoCreatorTest.java


示例14: testCreateServiceInfo_ServiceNoMetadata

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given a kubernetes service without metadata we launch a NPE")
public void testCreateServiceInfo_ServiceNoMetadata() throws Exception {

    Service service = new Service();
    service.setSpec(getServiceSpec());

    expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
 
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:10,代码来源:ConfigServerServiceInfoCreatorTest.java


示例15: testKubernetesServiceInfoCreatorFromServiceFile

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
@DisplayName("Given the service file, when we instantiate the content then we get a KubernetesServiceInfoCreator")
public void testKubernetesServiceInfoCreatorFromServiceFile() throws Exception {
    InputStream resourceAsStream = this.getClass().getResourceAsStream(
            "/META-INF/services/org.springframework.cloud.kubernetes.connector.KubernetesServiceInfoCreator");
    byte[] bytes = new byte[resourceAsStream.available()];
    resourceAsStream.read(bytes);
    Class<?> aClass = Class.forName(new String(bytes));
    Object o = aClass.newInstance();
    assertTrue(o instanceof KubernetesServiceInfoCreator);
}
 
开发者ID:serenity-devstack,项目名称:spring-cloud-services-connector,代码行数:12,代码来源:ConfigServerServiceInfoCreatorTest.java


示例16: mutatestSimpleCodeEndExecutesTest

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
void mutatestSimpleCodeEndExecutesTest() throws IOException, VerificationException {
    prepare("/simple");

    verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage");

    verifier.verifyTextInLog("Ran 1 tests");
    verifier.verifyTextInLog("Generated 1 mutations Killed 1");
}
 
开发者ID:KyleRogers,项目名称:pitest-junit-5-plugin,代码行数:10,代码来源:JUnit5IntegrationTest.java


示例17: executes

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
void executes() {
    final ProductionCode p = new ProductionCode();
    p.calculateOutput();

    assertTrue(p.ran);
}
 
开发者ID:KyleRogers,项目名称:pitest-junit-5-plugin,代码行数:8,代码来源:ProductionCodeTest.java


示例18: doesNotExecute

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
void doesNotExecute() {
    final ProductionCode p = new ProductionCode();
    p.x = 4;
    p.calculateOutput();

    assertFalse(p.ran);
}
 
开发者ID:KyleRogers,项目名称:pitest-junit-5-plugin,代码行数:9,代码来源:ProductionCodeTest.java


示例19: findsNoTestsOnNonTestClass

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
void findsNoTestsOnNonTestClass() {
    assertThat(testUnitFinder.findTestUnits(JUnit5Configuration.class), is(empty()));

    assertTrue(
            testUnitFinder.findTestUnits(JUnit5Configuration.class).isEmpty());
}
 
开发者ID:KyleRogers,项目名称:pitest-junit-5-plugin,代码行数:8,代码来源:JUnit5ConfigurationTest.java


示例20: findsTestsOnJUnit5TestClass

import org.junit.gen5.api.Test; //导入依赖的package包/类
@Test
void findsTestsOnJUnit5TestClass() {
    assertThat(testUnitFinder.findTestUnits(DummyTestClass.class), is(not(empty())));

    assertFalse(
            testUnitFinder.findTestUnits(DummyTestClass.class).isEmpty());
}
 
开发者ID:KyleRogers,项目名称:pitest-junit-5-plugin,代码行数:8,代码来源:JUnit5ConfigurationTest.java



注:本文中的org.junit.gen5.api.Test类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultNodeMatcher类代码示例发布时间:2022-05-23
下一篇:
Java TaskTrackerHealthStatus类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap