Skip to content
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

请问如何运行测试? #41

Open
nobodxbodon opened this issue Jul 28, 2021 · 5 comments
Open

请问如何运行测试? #41

nobodxbodon opened this issue Jul 28, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@nobodxbodon
Copy link
Contributor

在根目录下运行 src/test.py 未遍历所有例程:

$ python src/test.py 
==============START TEST================
=============END=======================
Finished in 0s!

另外,为自动验证运行结果,像 木兰重现项目之前这样 获取进程输出后与期望值作比较如何?

@StepfenShawn
Copy link
Owner

在src目录下可以运行测试:

> cd src
> python test.py

这个项目的测试并不能完全通过与期望值的比较来实现,像games, App, Web目录下的文件很难实现与期望值比较

@nobodxbodon
Copy link
Contributor Author

试了 src 目录下运行,还是同样输出:

==============START TEST================
=============END=======================
Finished in 0s!

关于部分测试没有输出因而无法比较期望值,木兰也有类似测试用例,比如 这些与界面相关的。木兰重现项目的自动测试是覆盖了语法功能测试等等,并且建了流水线(CI),以确保每次commit 都不会破坏基本功能:
Screen Shot 2021-07-28 at 7 24 54 PM

要不先将 basic/ 下的纳入自动测试?可以将其他有输出的用例逐步添加,以扩大测试覆盖面。

@StepfenShawn
Copy link
Owner

这么奇怪的吗? 我这里怎么能运行:

> cd src
> python test.py
==============START TEST================
Running:..\examples\algorithms\binary_search.cantonese......
揾到啦!!!
揾唔到: (
End
Running:..\examples\algorithms\bubble_sort.cantonese......
[11, 12, 22, 25, 34, 64, 90]
[12, 21, 22, 55, 77, 90, 97]
End
Running:..\examples\algorithms\factorial.cantonese......
2
720
End
Running:..\examples\algorithms\fib.cantonese......
55
1
End
Running:..\examples\algorithms\fizzbuzz.cantonese......
FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
End
Running:..\examples\algorithms\insert_sort.cantonese......
[11, 12, 22, 25, 34, 64, 90]
[12, 21, 22, 55, 77, 90, 97]
End
Running:..\examples\algorithms\linear_search.cantonese......
揾到啦:)
揾唔到:(
End
Running:..\examples\algorithms\max.cantonese......
34
27
End
Running:..\examples\algorithms\Tower_of_Hanoi.cantonese......
move A  to  B
move A  to  C
move B  to  C
move A  to  B
move C  to  A
move C  to  B
move A  to  B
move A  to  C
move B  to  C
move B  to  A
move C  to  A
move B  to  C
move A  to  B
move A  to  C
move B  to  C
End
Running:..\examples\basic\assert.cantonese......
濑嘢!AssertionError:
End
Running:..\examples\basic\assign.cantonese......
1
3
End
Running:..\examples\basic\class.cantonese......
Duck is swimming
Duck is sleeping
公
End
Running:..\examples\basic\comment.cantonese......
Run OK
End
Running:..\examples\basic\exit.cantonese......
执行exit
End
Running:..\examples\basic\for.cantonese......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
End
Running:..\examples\basic\function.cantonese......
Hello
SayFuck
Hello
End
Running:..\examples\basic\HelloWorld.cantonese......
 Hello World!
End
Running:..\examples\basic\if.cantonese......
A 系 3
B 系 1
End
Running:..\examples\basic\import.cantonese......
1
3
5.0
1
测试成功
End
Running:..\examples\basic\input.cantonese......
请输入你嘅名:

@StepfenShawn StepfenShawn added the bug Something isn't working label Jul 29, 2021
@nobodxbodon
Copy link
Contributor Author

哦你们都是 windows 环境吧?我是 mac。应该是路径斜杠问题,刚改成这样就好了:'../examples/*'

在木兰里为跨平台运行测试是用了 pathlib 的 Path,见此

nobodxbodon added a commit to nobodxbodon/Cantonese that referenced this issue Jul 29, 2021
StepfenShawn added a commit that referenced this issue Jul 29, 2021
#41 自动测试搭建, 第一批四个用例
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@nobodxbodon @StepfenShawn and others