跳到主要内容
知仓学习社ZHICANG

creating-julia-test-env

Use when you add tests for Julia packages

不碰外部(只输出文字)无严重或高危命中hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少1 个文本文件,2 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

creating-julia-test-env

A minimal Julia package layout looks like this:

$ tree
.
├── Project.toml
└── src
    └── MyPkg.jl # Assume the package is named MyPkg for this example.

To add software tests for this package, follow the steps below.

Step 1: Create the test directory, runtests.jl, and a Project.toml for the test environment.

mkdir test
touch test/runtests.jl
touch test/Project.toml

Step 2: Add a [workspace] section to ./Project.toml (not test/Project.toml):

name = "MyPkg"

...
...<omitted>
...

# Add this section
[workspace]
projects = ["test"]

Note: If you are on Julia 1.11 or older, do not use [workspace]. Instead, add [extras] and [targets]:

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

Step 3: Set up ./test/Project.toml as follows:

$ cd test
$ ls
runtests.jl Project.toml
$ julia --project -e 'using Pkg; Pkg.add("Test")'
$ julia --project -e 'using Pkg; Pkg.develop(path="../")'
$ cat Project.toml
[deps]
MyPkg = <UUID for MyPkg goes here>
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
MyPkg = {path = ".."}

Step 4: Put a simple sample test in test/runtests.jl (replace MyPkg with your actual package name).

using Test

using MyPkg

@testset "sample" begin
    @test 1 + 1 == 2
end

Step 5: Run the following to verify:

$ julia --project -e 'using Pkg; Pkg.test()'

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 1,027
本站分层T1
该仓技能数1910
原文件路径plugins/AtelierArith/atelier-arith-julia-development-skills/skills/creating-julia-test-env/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 1910 个技能