{"id":22604525,"url":"https://github.com/shinshin86/go-te","last_synced_at":"2026-05-05T05:36:37.037Z","repository":{"id":57694729,"uuid":"487789312","full_name":"shinshin86/go-te","owner":"shinshin86","description":"te(Tiny Expect) is a tiny test library for go.","archived":false,"fork":false,"pushed_at":"2022-06-26T05:25:16.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-03T07:44:53.886Z","etag":null,"topics":["golang","test","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinshin86.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-02T09:37:47.000Z","updated_at":"2022-12-05T14:45:15.000Z","dependencies_parsed_at":"2022-09-26T21:01:34.338Z","dependency_job_id":null,"html_url":"https://github.com/shinshin86/go-te","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinshin86%2Fgo-te","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinshin86%2Fgo-te/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinshin86%2Fgo-te/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinshin86%2Fgo-te/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinshin86","download_url":"https://codeload.github.com/shinshin86/go-te/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246102929,"owners_count":20723877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","test","testing","testing-tools"],"created_at":"2024-12-08T13:09:40.196Z","updated_at":"2026-05-05T05:36:37.009Z","avatar_url":"https://github.com/shinshin86.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# (WIP) go-te 💨\n[![CI](https://github.com/shinshin86/go-te/actions/workflows/ci.yml/badge.svg)](https://github.com/shinshin86/go-te/actions/workflows/ci.yml)\n\nte(Tiny Expect) is a tiny test library for go.\n\n## Note\nte is not recommended for use, although I have using it myself in very limited circumstances.  \n(This one was created with a bit of an idea in mind).\n\nIt also does not have all the features needed for testing, so please use it for fun only.\n\n## Install\nPlease install it to perform the test with the command `go-te`.  \n(`go-te` uses generics and should be used with `1.18` or later versions of Go.)\n\n```sh\ngo install github.com/shinshin86/go-te@latest\n```\n\nIt must then be added to the project to be used.\n\n```sh\ngo get github.com/shinshin86/go-te\n```\n\n\n## Usage\n\nThis is a simple example.\n\n```go\npackage main\n\nimport (\n\t. \"github.com/shinshin86/go-te/te\"\n)\n\nfunc main() {\n\tt := Init()\n\n\tt.Describe(\"Expect to be sample\", func() {\n\t\tt.It(\"Expect b is true\", func() {\n\t\t\tb := true\n\t\t\tt.Expect(b).ToBe(true)\n\t\t})\n\n\t\tt.It(\"Expect i is 1\", func() {\n\t\t\ti := 1\n\t\t\tt.Expect(i).ToBe(1)\n\t\t})\n\n\t\t// The name Test is also available. The functionality is the same.\n\t\tt.Test(\"Expect s is helloworld\", func() {\n\t\t\ts := \"helloworld\"\n\t\t\tt.Expect(s).ToBe(\"helloworld\")\n\t\t})\n\t})\n\n\tt.Describe(\"Expoect not to be test\", func() {\n\t\tt.It(\"Expect b is not true\", func() {\n\t\t\tb := true\n\t\t\tt.Expect(b).NotToBe(false)\n\t\t})\n\n\t\tt.It(\"Expect i is not 1\", func() {\n\t\t\ti := 1\n\t\t\tt.Expect(i).NotToBe(2)\n\t\t})\n\t})\n\n\tt.Exit()\n}\n```\n\n## Setup and Teardown\n\nOften, there are cases where you want to do specific processing before and after the test is run. te also provides helper functions to assist in these cases.\n\nNote that these helper functions must be defined prior to test execution.\n\nThe functions provided are as follows.\n\n* BeforeAll\n* AfterAll\n* BeforeEach\n* AfterEach\n\nAn example of use can be found here.\n\n```go\nfunc main() {\n\tt := Init()\n\n\tcwd, _ := os.Getwd()\n\n\tfilename := \"test.txt\"\n\ttesttxt := \"Setup and Teardown test\"\n\n\tnum := 1\n\n\tt.BeforeAll(func() {\n\t\tfp, err := os.Create(filepath.Join(cwd, \"_example\", filename))\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\n\t\tdefer fp.Close()\n\n\t\tfp.WriteString(testtxt)\n\t})\n\n\tt.AfterAll(func() {\n\t\tif err := os.Remove(filepath.Join(cwd, \"_example\", filename)); err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t})\n\n\tt.BeforeEach(func() {\n\t\tnum++\n\t})\n\n\tt.AfterEach(func() {\n\t\tnum++\n\t})\n\n\tt.Describe(\"Setup and Teardown test\", func() {\n\t\tt.It(\"Expected a file strings are the same\", func() {\n\t\t\tf, _ := os.Open(filepath.Join(cwd, \"_example\", filename))\n\n\t\t\tdefer f.Close()\n\n\t\t\tb, _ := ioutil.ReadAll(f)\n\n\t\t\tt.Expect(string(b)).ToBe(testtxt)\n\t\t})\n\n\t\tt.It(\"Expected the variable num to be incremented a specified number of times\", func() {\n\t\t\t// 1 -\u003e 2(BeforeEach) -\u003e 3(AfterEach) -\u003e 4(BeforeEach: this function)\n\t\t\tt.Expect(num).ToBe(4)\n\t\t})\n\t})\n\n\tt.Exit()\n}\n```\n\n## Command line options\n\n```sh\ngo-te --help\n\n# -c string\n#   \tSpecify config file path (default \"te.config.json\")\n# -d string\n#   \tSpecify test directory (default \"test\")\n# -m string\n#   \tSpecify match files (default \"*.go\")\n```\n\n## Config file\nYou can create a `te.config.json` file and put runtime test options there.\n\n```json\n{\n    \"testMatch\": [\"_example/*.go\", \"_example/sub/*.go\"]\n}\n```\n\n - `testMatch` - You can specify the path to the test file.\n\n## About Test File Names\nThere are no specific rules about files for testing in `go-te`.\nHowever, as a specification of go, files with `_test.go` such as `foo_test.go` cannot be used.\n\n## Examples\n\nYou can also try the example code for this project.  \nExecute the following command.\n\n```sh\n# install\ngo install github.com/shinshin86/go-te@latest\n\n# project clone\ngit clone https://github.com/shinshin86/go-te.git\ncd go-te\n\n# run\ngo-te -d _example\n```\n\n## Running Tests\nTests are performed on code written under the `_example` directory.\n\n```sh\nmake test\n```\n\n## License\n[MIT](https://github.com/shinshin86/go-te/blob/main/LICENSE)\n\n## Author\n[Yuki Shindo](https://shinshin86.com/en)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinshin86%2Fgo-te","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinshin86%2Fgo-te","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinshin86%2Fgo-te/lists"}