EE308 Lab11

crisitianoyyb crisitianoyyb 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
The Link Your Classhttps://bbs.csdn.net/forums/MUEE308FZ
The Goal of This AssignmentSoftware Testing
Leader's MU STU ID and Name19103379_831902122
Teammate 1's MU STU ID and Name19104065_831902128
Teammate 2's MU STU ID and Name19103913_831902127
Teammate 3's MU STU ID and Name19103964_831902125
Teammate 4's MU STU ID and Name19104090_831902111

We test some functions of our back-end part of the program.

1. Junit assert test

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bcslr.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.example.bcslr.entity.User;
import org.springframework.test.context.junit4.SpringRunner;
// import org.junit.rules.ExpectedException;
// import org.springframework.util.Assert;
// import static org.junit.Assert.*;


import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j


class BcslrApplicationTests extends ServiceImpl<UserMapper, User> {
    @Test
    public void test() {
        // add assert test code between Begin and End, no other change allowed
        /***********************Begin**************************/
        Assert.assertEquals("var1" , var2, var1); //
        // for example
        /************************End***************************/
    }
}

img

img

The Junit assertEquals function can check whether two values are same, and give the corresponding output like the error information.

2. Junit time test


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bcslr.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.example.bcslr.entity.User;
import org.springframework.test.context.junit4.SpringRunner;
// import org.junit.rules.ExpectedException;
// import org.springframework.util.Assert;
// import static org.junit.Assert.*;


import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j


class BcslrApplicationTests extends ServiceImpl<UserMapper, User> {
 /*
    test timeout function
    */
    @Test()
    public void testTimeout(){
        log.info("yybzjbs");
        while(true){
            log.info("yybzjbs");
        }
    }
}

img

The Junit time test function are capable to prevent the function run for overlong time, it can prevent them to run when the function reaches the timeout function limitation and output the wrong information.

3. Junit parameterized test

package com.example.bcslr;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.example.bcslr.Calculate;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

/**
 * JUnit4 parameterized test
 */
@RunWith(Parameterized.class)
public class ParameterTest {

    private final int input11;
    private final int input22;
    private final int expected;

    public ParameterTest(int input11, int input22, int expected) {
        this.input11 = input11;
        this.input22 = input22;
        this.expected = expected;
    }

    @Parameterized.Parameters()
    public static Collection<Object> prepareData() {
        return Arrays.asList(new Object[][]{
                {3, 1, 2}, {5, 2, 3}//, {3,4,5}, {6,7,8}
        });
    }

    @Test
    public void testSub() {
        Calculator cal = new Calculator();
        assertEquals(cal.sub(input11, input22), expected);
    }
    // Calculator.java Junit Parameterized Test
    /**
     * Mathematical Calculation  subtract
     */
    public class Calculator {
        public int sub(int a, int b) {
            return a - b;
        }
    }

}

img

Junit parameterized test function makes it possible to run tests with multiple kinds of parameters, in we can test multiple parameters.

4. Junit Exception Test

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bcslr.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.example.bcslr.entity.User;
import org.springframework.test.context.junit4.SpringRunner;
// import org.junit.rules.ExpectedException;
// import org.springframework.util.Assert;
// import static org.junit.Assert.*;


import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j


class BcslrApplicationTests extends ServiceImpl<UserMapper, User> {
    @Test
    void testnegid() {
        User user = new User();
        user.setName("王宁");
        user.setAge(-1);//怎么改id??
    }

}

img

Junit Exception Test will stick with the functions in the original places and throw exceptions as usual.

5. Junit Suite Test

package com.example.bcslr;

import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;


@RunWith(Suite.class)
@Suite.SuiteClasses({TestDemo2.class,TestDemo.class})
public class TestSuite {

    @org.junit.Test(timeout = 1000)
    public void test2() {
        // log.info("yybzjbs");

        //log.info("yybzjbs");
        System.out.println(1);

    }
}


img

The two functions in the TestDemo2.java file are able to run fluently by using the junit.

img

The two functions in the TestDemo1.java file are able to run fluently by using the junit.

img

Junit Suite Test is capable to test the subset functions and files from the java files that include by Suite functions. In this way, it test all the functions and cases from TestDemo.java file and TestDemo2.java file. And, we can see the four cases all pass fluently like we test them individually, and we can see the running performance individually.

...全文

相关推荐

EE-308 LAB4 final version.7z

这是本次实验的压缩包

晨起剪桃花

EE308-Lab11-Software Testing

unittest for Python

调参侠鱼尾

EE308-Lab8-AlphaSprint Collection

EE308 Lab8 Alpha Sprint Collection1. Format Description2. 宁可累死自己,也要卷死同学 -Sprint Collection 1. Format Description The Link Your Class https://bbs.csdn.net/forums/MUEE308FZ The Link of Requirement of This Assignment https://bbs.csdn.net/topics/603251

调参侠鱼尾

【信息科学与工程学】【物理/化学科学和工程技术】知识体系073——电学基础04

​。

flyair_China

【自然语言处理】基于CRISPE与BROKE框架的提示词工程应用:大语言模型内容生成中的写作方法优化研究

内容概要:本文探讨提示词工程在人工智能内容生成中的关键作用,以CRISPE与BROKE两个提示词框架为例,分析其在角色设定、背景约束、验收标准和迭代机制上的异同,并通过撰写“AI与就业”科普短文的实际案例,展示提示词从模糊任务到可执行指令的构建过程。研究指出,提示词工程的核心不在于模板记忆,而在于提升意图的清晰度、约束的精确性、输出的可评测性以及对模型能力边界的认知。文章强调,有效的提示需明确角色、背景、任务、风格与验收标准,并通过多轮实验与迭代优化结果,避免生成内容陷入形式化与模板化。; 适合人群:具备一定AI基础知识、正在学习或使用大语言模型进行内容创作的学生、研究人员及内容创作者,尤其是关注写作质量与个性化表达的用户。; 使用场景及目标:①掌握如何将模糊写作意图转化为结构化提示词;②提升AI生成内容的信息密度、可读性与实用性;③在科研写作、科普传播等场景中保留个人思考痕迹,避免机械化表达;④学会通过可检查的验收标准持续优化输出。; 阅读建议:此资源不仅介绍提示词框架的操作方法,更强调思维训练。建议读者结合自身写作任务,动手实践CRISPE与BROKE的组合应用,重点关注约束设计与结果评测环节,并反思“为何提示无效”,从而真正实现从“会问”到“会写”的跃迁。

beiningya
评论
收藏 已收藏
分享
返回顶部